diff --git a/src/metadata/file.rs b/src/metadata/file.rs index 25fa7c93..406052d4 100644 --- a/src/metadata/file.rs +++ b/src/metadata/file.rs @@ -110,14 +110,14 @@ impl File { } /// Represents a case-insensitive filename. -#[derive(Clone, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)] -pub struct Filename(UniCase); +#[derive(Clone, Debug, Default)] +pub struct Filename(String); impl Filename { /// Construct a Filename using the given string. #[must_use] pub fn new(s: String) -> Self { - Filename(UniCase::new(s)) + Filename(s) } /// Get this Filename as a string. @@ -126,6 +126,32 @@ impl Filename { } } +impl PartialEq for Filename { + fn eq(&self, other: &Self) -> bool { + unicase::eq(&self.0, &other.0) + } +} + +impl Eq for Filename {} + +impl PartialOrd for Filename { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for Filename { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + UniCase::new(&self.0).cmp(&UniCase::new(&other.0)) + } +} + +impl std::hash::Hash for Filename { + fn hash(&self, state: &mut H) { + UniCase::new(&self.0).hash(state); + } +} + impl AsRef for &Filename { fn as_ref(&self) -> &str { &self.0