From 9e6a2c9d83272113711d3dc6c57162caa2c189b3 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 15 Mar 2026 23:15:01 +0100 Subject: Simplify code --- oryxc/src/unistr.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'oryxc') diff --git a/oryxc/src/unistr.rs b/oryxc/src/unistr.rs index 1d8463d..158fed1 100644 --- a/oryxc/src/unistr.rs +++ b/oryxc/src/unistr.rs @@ -46,13 +46,9 @@ impl PartialEq for UniStr<'_> { == IsNormalized::Yes, ) { (true, true) => self.0 == other.0, - (true, false) => { - self.0.chars().map(|b| b as char).eq(other.0.nfkd()) - }, - (false, true) => { - self.0.nfkd().eq(other.0.chars().map(|b| b as char)) - }, - (false, false) => self.0.nfkd().eq(other.0.nfkd()), + (true, false) => self.0.chars() == other.0.nfkd(), + (false, true) => self.0.nfkd() == other.0.chars(), + (false, false) => self.0.nfkd() == other.0.nfkd(), }; } } @@ -74,6 +70,11 @@ mod tests { assert_eq!(UniStr("fishi"), UniStr("fishᵢ")); assert_eq!(UniStr("fishᵢ"), UniStr("fishᵢ")); assert_eq!(UniStr("corné"), UniStr("corné")); + assert_eq!(UniStr("fishᵢ"), UniStr("fishi")); + assert_eq!(UniStr("fishi"), UniStr("fishi")); + assert_eq!(UniStr("fishᵢ"), UniStr("fishi")); + assert_eq!(UniStr("fishᵢ"), UniStr("fishᵢ")); + assert_eq!(UniStr("corné"), UniStr("corné")); } #[test] @@ -84,6 +85,11 @@ mod tests { (UniStr("fishi"), UniStr("fishᵢ")), (UniStr("fishᵢ"), UniStr("fishᵢ")), (UniStr("corné"), UniStr("corné")), + (UniStr("fishᵢ"), UniStr("fishi")), + (UniStr("fishi"), UniStr("fishi")), + (UniStr("fishᵢ"), UniStr("fishi")), + (UniStr("fishᵢ"), UniStr("fishᵢ")), + (UniStr("corné"), UniStr("corné")), ] { let mut hashl = DefaultHasher::new(); let mut hashr = DefaultHasher::new(); -- cgit v1.2.3