From 43996db0eab8438442a417be16a40dacf1d8b87f Mon Sep 17 00:00:00 2001 From: Mike Welsh Date: Sun, 8 May 2022 11:39:41 -0700 Subject: [PATCH] core: Add WStr::eq_with_case --- wstr/src/common.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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.