aboutsummaryrefslogtreecommitdiff
path: root/src/dictionary.rs
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2023-07-06 14:05:39 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2023-07-06 14:05:39 +0200
commit8c3c8efa428200c67c1a6fa731faee55adf19678 (patch)
tree40f96ad5bd9bb86c62a84bd05914afcf345c6a05 /src/dictionary.rs
parent8799c886003d5eb0084589776ccafea809c451ff (diff)
cleanup with clippy
Diffstat (limited to 'src/dictionary.rs')
-rw-r--r--src/dictionary.rs9
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);
}
}