From 831942c2e2ec86ff7d8b1e576fbb61eb1d7ef9c5 Mon Sep 17 00:00:00 2001 From: abdo Date: Thu, 14 Jan 2021 06:46:31 +0300 Subject: [PATCH] Fix unicode tag sorting --- rslib/src/tags.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rslib/src/tags.rs b/rslib/src/tags.rs index 1ae6a69c9..00c52adf3 100644 --- a/rslib/src/tags.rs +++ b/rslib/src/tags.rs @@ -28,7 +28,7 @@ pub struct Tag { impl Ord for Tag { fn cmp(&self, other: &Self) -> Ordering { - self.name.cmp(&other.name) + UniCase::new(&self.name).cmp(&UniCase::new(&other.name)) } } @@ -40,7 +40,7 @@ impl PartialOrd for Tag { impl PartialEq for Tag { fn eq(&self, other: &Self) -> bool { - self.name == other.name + self.cmp(other) == Ordering::Equal } } @@ -121,7 +121,7 @@ fn normalize_tag_name(name: &str) -> String { } fn fill_missing_tags(tags: Vec) -> Vec { - let mut filled_tags: HashMap = HashMap::new(); + let mut filled_tags: HashMap = HashMap::with_capacity(tags.len()); for tag in tags.into_iter() { let name = tag.name.to_owned(); let split: Vec<&str> = (&tag.name).split("::").collect();