We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
IteratorUtil::to_vec()
1 parent dbbc244 commit f7e58ebCopy full SHA for f7e58eb
src/libcore/iterator.rs
@@ -45,6 +45,7 @@ pub trait IteratorUtil<A> {
45
fn advance(&mut self, f: &fn(A) -> bool);
46
#[cfg(not(stage0))]
47
fn advance(&mut self, f: &fn(A) -> bool) -> bool;
48
+ fn to_vec(self) -> ~[A];
49
}
50
51
/// Iterator adaptors provided for every `Iterator` implementation. The adaptor objects are also
@@ -131,6 +132,14 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
131
132
133
134
135
+
136
+ #[inline(always)]
137
+ fn to_vec(self) -> ~[A] {
138
+ let mut v = ~[];
139
+ let mut it = self;
140
+ for it.advance() |x| { v.push(x); }
141
+ return v;
142
+ }
143
144
145
pub struct ChainIterator<T, U> {
0 commit comments