Skip to content

Commit

Permalink
Use assertions in find_with_or_insert_with example
Browse files Browse the repository at this point in the history
This lets us test it automatically and also makes it more obvious what
the expected result is.
  • Loading branch information
chris-morgan committed May 15, 2014
1 parent 73dc1e0 commit 5b13ddb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/libcollections/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1299,9 +1299,10 @@ impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
/// );
/// }
///
/// for (k, v) in map.iter() {
/// println!("{} -> {}", *k, *v);
/// }
/// assert_eq!(map.len(), 3);
/// assert_eq!(map.get(&"a key"), &vec!["value", "new value"]);
/// assert_eq!(map.get(&"b key"), &vec!["new value"]);
/// assert_eq!(map.get(&"z key"), &vec!["new value", "value"]);
/// ```
pub fn find_with_or_insert_with<'a, A>(&'a mut self,
k: K,
Expand Down

1 comment on commit 5b13ddb

@lilyball
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+

Please sign in to comment.