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