summaryrefslogtreecommitdiff
path: root/oryxc/src
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2026-03-15 23:15:01 +0100
committerThomas Voss <mail@thomasvoss.com> 2026-03-15 23:15:01 +0100
commit9e6a2c9d83272113711d3dc6c57162caa2c189b3 (patch)
treeada355e168a29cf3de3693fd17130e88d296183e /oryxc/src
parent71bee557fcea066cddc58d805c1c38a240b074cc (diff)
Simplify code
Diffstat (limited to 'oryxc/src')
-rw-r--r--oryxc/src/unistr.rs20
1 files changed, 13 insertions, 7 deletions
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();