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