@@ -83,12 +83,38 @@ impl<T: Ord> BTreeSet<T> {
83
83
84
84
impl < T > BTreeSet < T > {
85
85
/// Gets an iterator over the BTreeSet's contents.
86
+ ///
87
+ /// # Examples
88
+ ///
89
+ /// ```
90
+ /// use std::collections::BTreeSet;
91
+ ///
92
+ /// let set: BTreeSet<uint> = [1u, 2, 3, 4].iter().map(|&x| x).collect();
93
+ ///
94
+ /// for x in set.iter() {
95
+ /// println!("{}", x);
96
+ /// }
97
+ ///
98
+ /// let v: Vec<uint> = set.iter().map(|&x| x).collect();
99
+ /// assert_eq!(v, vec![1u,2,3,4]);
100
+ /// ```
86
101
#[ unstable = "matches collection reform specification, waiting for dust to settle" ]
87
102
pub fn iter < ' a > ( & ' a self ) -> Items < ' a , T > {
88
103
Items { iter : self . map . keys ( ) }
89
104
}
90
105
91
106
/// Gets an iterator for moving out the BtreeSet's contents.
107
+ ///
108
+ /// # Examples
109
+ ///
110
+ /// ```
111
+ /// use std::collections::BTreeSet;
112
+ ///
113
+ /// let set: BTreeSet<uint> = [1u, 2, 3, 4].iter().map(|&x| x).collect();
114
+ ///
115
+ /// let v: Vec<uint> = set.into_iter().collect();
116
+ /// assert_eq!(v, vec![1u,2,3,4]);
117
+ /// ```
92
118
#[ unstable = "matches collection reform specification, waiting for dust to settle" ]
93
119
pub fn into_iter ( self ) -> MoveItems < T > {
94
120
fn first < A , B > ( ( a, _) : ( A , B ) ) -> A { a }
0 commit comments