Skip to content

Commit

Permalink
Add into_map function
Browse files Browse the repository at this point in the history
This is useful when i.e. you need to return a HashMap from a function,
and you're hiding the use of a Counter as an implementation detail.

Closes #6.
  • Loading branch information
coriolinus committed Aug 7, 2018
1 parent cb24e7f commit 56c4e94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "counter"
version = "0.4.0"
version = "0.4.1"
authors = ["Peter Goodspeed-Niklaus <peter.r.goodspeedniklaus@gmail.com>"]
description = "Simple package to count generic iterables"
repository = "https://github.com/coriolinus/counter-rs"
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ where
}
}
}

/// Consumes this counter and returns a HashMap mapping the items to the counts.
pub fn into_map(self) -> HashMap<T, N> {
self.map
}
}

impl<T, N> Counter<T, N>
Expand Down

0 comments on commit 56c4e94

Please sign in to comment.