Skip to content

Commit

Permalink
🏷️ Use custom hash for Language
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenixr-codes committed Oct 18, 2024
1 parent fd00cea commit 3a09dd0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/localization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -574,6 +575,12 @@ impl Language {
}
}

impl Hash for Language {
fn hash<H: std::hash::Hasher>(&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()
Expand Down

0 comments on commit 3a09dd0

Please sign in to comment.