From 3a09dd030147fe9d78ffef4c51484ffab4ac3590 Mon Sep 17 00:00:00 2001 From: Jonas da Silva Date: Fri, 18 Oct 2024 14:28:48 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20Use=20custom=20hash=20f?= =?UTF-8?q?or=20`Language`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/localization.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/localization.rs b/src/localization.rs index ab0d136..3211e8e 100644 --- a/src/localization.rs +++ b/src/localization.rs @@ -3,6 +3,7 @@ use std::collections::HashMap; use std::fmt; use std::fs; use std::fs::OpenOptions; +use std::hash::Hash; use std::io::Write; use std::path::PathBuf; @@ -310,7 +311,7 @@ mod by_id { // FIXME: always serialized to Other (which is fine but makes all other options redundant and may be an issue // in the future as only the vanilla languages have a name which is nicer for printing). /// Languages that can be used for translation. -#[derive(Clone, Debug, Default, Eq, Hash, Deserialize)] +#[derive(Clone, Debug, Default, Eq, Deserialize)] #[non_exhaustive] #[serde(untagged)] #[cfg_attr( @@ -574,6 +575,12 @@ impl Language { } } +impl Hash for Language { + fn hash(&self, state: &mut H) { + self.file_id().hash(state); + } +} + impl PartialEq for Language { fn eq(&self, other: &Self) -> bool { self.file_id() == other.file_id()