about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Morgan <me@chrismorgan.info>2014-05-15 10:28:48 +1000
committerChris Morgan <me@chrismorgan.info>2014-05-15 10:28:48 +1000
commit5b13ddb5f2da143f46240c5933fba2a035e68102 (patch)
treefb3c5281728d72a65e81b5fff30411af652aaa80
parent73dc1e016d342d46f1fdeffb9aab75c5ecc5a20b (diff)
downloadrust-5b13ddb5f2da143f46240c5933fba2a035e68102.tar.gz
rust-5b13ddb5f2da143f46240c5933fba2a035e68102.zip
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.
-rw-r--r--src/libcollections/hashmap.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libcollections/hashmap.rs b/src/libcollections/hashmap.rs
index 35a89fe5dc5..87dc97d70c7 100644
--- a/src/libcollections/hashmap.rs
+++ b/src/libcollections/hashmap.rs
@@ -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,