Skip to content
Closed
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
13 changes: 13 additions & 0 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,19 @@ pub trait Iterator<A> {
}
}

/// Applies the specified function to each element yielded by the iterator
///
/// # Example
///
/// ```rust
/// let a = [1, 2, 3];
/// a.iter().for_each(|x| println!("{}", x));
/// ```
#[inline]
fn for_each(&mut self, f: |A|) {
for x in *self { f(x); }
}

/// Loops through the entire iterator, collecting all of the elements into
/// a container implementing `FromIterator`.
///
Expand Down