Skip to content

Commit 5b13ddb

Browse files
committed
Use assertions in find_with_or_insert_with example
This lets us test it automatically and also makes it more obvious what the expected result is.
1 parent 73dc1e0 commit 5b13ddb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/libcollections/hashmap.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,9 +1299,10 @@ impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
12991299
/// );
13001300
/// }
13011301
///
1302-
/// for (k, v) in map.iter() {
1303-
/// println!("{} -> {}", *k, *v);
1304-
/// }
1302+
/// assert_eq!(map.len(), 3);
1303+
/// assert_eq!(map.get(&"a key"), &vec!["value", "new value"]);
1304+
/// assert_eq!(map.get(&"b key"), &vec!["new value"]);
1305+
/// assert_eq!(map.get(&"z key"), &vec!["new value", "value"]);
13051306
/// ```
13061307
pub fn find_with_or_insert_with<'a, A>(&'a mut self,
13071308
k: K,

0 commit comments

Comments
 (0)