diff --git a/wstr/src/common.rs b/wstr/src/common.rs index e32e16ff3435..cb76e0967846 100644 --- a/wstr/src/common.rs +++ b/wstr/src/common.rs @@ -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>, + 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.