diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-07-06 14:05:39 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-07-06 14:05:39 +0200 |
| commit | 8c3c8efa428200c67c1a6fa731faee55adf19678 (patch) | |
| tree | 40f96ad5bd9bb86c62a84bd05914afcf345c6a05 /src/dictionary.rs | |
| parent | 8799c886003d5eb0084589776ccafea809c451ff (diff) | |
cleanup with clippy
Diffstat (limited to 'src/dictionary.rs')
| -rw-r--r-- | src/dictionary.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/dictionary.rs b/src/dictionary.rs index b522c9e..e0a561a 100644 --- a/src/dictionary.rs +++ b/src/dictionary.rs @@ -6,6 +6,11 @@ pub struct Dictionary { data : HashMap<String, u64>, } +impl Default for Dictionary { + fn default() -> Self { + Self::new() + } +} impl Dictionary { pub fn new() -> Self { @@ -25,9 +30,9 @@ impl Dictionary { } pub fn set(&mut self, name : String) { - if !self.data.contains_key(&name) { + if let std::collections::hash_map::Entry::Vacant(e) = self.data.entry(name) { self.last_index += 1; - self.data.insert(name, self.last_index as u64); + e.insert(self.last_index as u64); } } |