Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/std-types/exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ impl Counter {
}
}

/// Count an occurrence of the given value.
fn count(&mut self, value: u32) {
if self.values.contains_key(&value) {
*self.values.get_mut(&value).unwrap() += 1;
/// Count an occurrence of the given key.
fn count(&mut self, key: u32) {
if self.values.contains_key(&key) {
*self.values.get_mut(&key).unwrap() += 1;
} else {
self.values.insert(value, 1);
self.values.insert(key, 1);
}
}

/// Return the number of times the given value has been seen.
fn times_seen(&self, value: u32) -> u64 {
self.values.get(&value).copied().unwrap_or_default()
/// Return the number of times the given key has been seen.
fn times_seen(&self, key: u32) -> u64 {
self.values.get(&key).copied().unwrap_or_default()
}
}

Expand Down