Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions stdlib/traits.affine
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ pub trait Iterator {
return n;
}

/// Collect into Vec
pub fn collect(mut self) -> Vec[Item] {
let mut result = Vec::new();
/// Collect into a list. (`Vec` is not a stdlib type; the stdlib
/// builds lists with `[]` + `++`, as in prelude/option/result —
/// #135 slice 4-traits.)
pub fn collect(mut self) -> [Item] {
let mut result = [];
while let Some(item) = self.next() {
result.push(item);
result = result ++ [item];
}
return result;
}
Expand Down
Loading