core: Add WStr::eq_with_case

This commit is contained in:
Mike Welsh 2022-05-08 11:39:41 -07:00
parent 4f05d1852d
commit 9d5e461278
1 changed files with 15 additions and 0 deletions

View File

@ -289,6 +289,21 @@ impl WStr {
super::ops::str_eq_ignore_case(self, other)
}
#[inline]
/// Compares two strings with the specified case sensitivity.
/// Note that the case mapping is different than Rust's case mapping.
pub fn eq_with_case<'a>(
&self,
other: impl Into<Units<&'a [u8], &'a [u16]>>,
case_sensitive: bool,
) -> bool {
if case_sensitive {
self == WStr::from_units(other.into())
} else {
self.eq_ignore_case(WStr::from_units(other.into()))
}
}
#[inline]
/// Compares two strings, ignoring case as done by the Flash Player.
/// Note that the case mapping is different than Rust's case mapping.