Navigation Menu

Skip to content

Commit

Permalink
Add a doctest for BTreeMap's iter method.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbranchaud committed Dec 6, 2014
1 parent 6f4c11b commit 9cb26e2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/libcollections/btree/map.rs
Expand Up @@ -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();
Expand Down

0 comments on commit 9cb26e2

Please sign in to comment.