From 3b619c4ca5dbb12236fddfb9f96ae34c8554d3af Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 3 Apr 2020 19:31:59 +1000 Subject: [PATCH] use case folding when sorting in canonify --- rslib/src/tags.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rslib/src/tags.rs b/rslib/src/tags.rs index 92267597c..fe025ca91 100644 --- a/rslib/src/tags.rs +++ b/rslib/src/tags.rs @@ -5,6 +5,7 @@ use crate::collection::Collection; use crate::err::Result; use crate::types::Usn; use std::{borrow::Cow, collections::HashSet}; +use unicase::UniCase; fn split_tags(tags: &str) -> impl Iterator { tags.split(|c| c == ' ' || c == '\u{3000}') @@ -23,7 +24,7 @@ impl Collection { if matches!(tag, Cow::Borrowed(_)) { added = true; } - tagset.insert(tag); + tagset.insert(UniCase::new(tag)); } if tagset.is_empty() { @@ -33,6 +34,8 @@ impl Collection { let mut tags = tagset.into_iter().collect::>(); tags.sort_unstable(); + let tags: Vec<_> = tags.into_iter().map(|s| s.into_inner()).collect(); + Ok((format!(" {} ", tags.join(" ")), added)) }