diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-09 09:24:48 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-09 09:24:48 -0800 |
| commit | ae60f9c59289adf8e46b2b3152f618caffc74bf4 (patch) | |
| tree | ad591c0f23114beb7a1eaf82f24141eb37e060f4 /src | |
| parent | 63ef9e980f8b7b584b001ef4e703fc8b2a1ab27a (diff) | |
| parent | 9cb26e2db052601db95e242c7c29caa744886b11 (diff) | |
| download | rust-ae60f9c59289adf8e46b2b3152f618caffc74bf4.tar.gz rust-ae60f9c59289adf8e46b2b3152f618caffc74bf4.zip | |
rollup merge of #19592: jbranchaud/add-btreemap-iter-doctest
I'm interested in including doctests for `BTreeMap`'s `iter_mut` and `into_iter` methods in this PR as well, but I am not sure of the best way to demonstrate/test what they do for the doctests.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcollections/btree/map.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index b3dc9139eb3..86eaa04b3e2 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -1026,6 +1026,24 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> { impl<K, V> BTreeMap<K, V> { /// Gets an iterator over the entries of the map. + /// + /// # Example + /// + /// ``` + /// use std::collections::BTreeMap; + /// + /// let mut map = BTreeMap::new(); + /// map.insert(1u, "a"); + /// map.insert(2u, "b"); + /// map.insert(3u, "c"); + /// + /// for (key, value) in map.iter() { + /// println!("{}: {}", key, value); + /// } + /// + /// let (first_key, first_value) = map.iter().next().unwrap(); + /// assert_eq!((*first_key, *first_value), (1u, "a")); + /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn iter<'a>(&'a self) -> Entries<'a, K, V> { let len = self.len(); |
