Skip to content

Commit

Permalink
Indicate that BTreeSet::iter returns values in ascending order.
Browse files Browse the repository at this point in the history
Fixes #38204.
  • Loading branch information
frewsxcv committed Dec 20, 2016
1 parent 4c4e8c4 commit fe0d092
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/libcollections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl<T: Ord> BTreeSet<T> {
}

impl<T> BTreeSet<T> {
/// Gets an iterator over the `BTreeSet`'s contents.
/// Gets an iterator that visits the values in the `BTreeSet` in ascending order.
///
/// # Examples
///
Expand All @@ -187,6 +187,19 @@ impl<T> BTreeSet<T> {
/// assert_eq!(set_iter.next(), Some(&3));
/// assert_eq!(set_iter.next(), None);
/// ```
///
/// Values returned by the iterator are returned in ascending order:
///
/// ```
/// use std::collections::BTreeSet;
///
/// let set: BTreeSet<usize> = [3, 1, 2].iter().cloned().collect();
/// let mut set_iter = set.iter();
/// assert_eq!(set_iter.next(), Some(&1));
/// assert_eq!(set_iter.next(), Some(&2));
/// assert_eq!(set_iter.next(), Some(&3));
/// assert_eq!(set_iter.next(), None);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn iter(&self) -> Iter<T> {
Iter { iter: self.map.keys() }
Expand Down

0 comments on commit fe0d092

Please sign in to comment.