mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-11 15:23:05 +00:00
stabilized iterator_for_each (closes #42986)
updated clippy and rls as it uses the iterator_for_each
This commit is contained in:
parent
ae8efdc87d
commit
b7152901ce
@ -1,17 +0,0 @@
|
||||
# `iterator_for_each`
|
||||
|
||||
The tracking issue for this feature is: [#42986]
|
||||
|
||||
[#42986]: https://github.com/rust-lang/rust/issues/42986
|
||||
|
||||
------------------------
|
||||
|
||||
To call a closure on each element of an iterator, you can use `for_each`:
|
||||
|
||||
```rust
|
||||
#![feature(iterator_for_each)]
|
||||
|
||||
fn main() {
|
||||
(0..10).for_each(|i| println!("{}", i));
|
||||
}
|
||||
```
|
@ -498,8 +498,6 @@ pub trait Iterator {
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(iterator_for_each)]
|
||||
///
|
||||
/// use std::sync::mpsc::channel;
|
||||
///
|
||||
/// let (tx, rx) = channel();
|
||||
@ -514,15 +512,13 @@ pub trait Iterator {
|
||||
/// might be preferable to keep a functional style with longer iterators:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(iterator_for_each)]
|
||||
///
|
||||
/// (0..5).flat_map(|x| x * 100 .. x * 110)
|
||||
/// .enumerate()
|
||||
/// .filter(|&(i, x)| (i + x) % 3 == 0)
|
||||
/// .for_each(|(i, x)| println!("{}:{}", i, x));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "iterator_for_each", issue = "42986")]
|
||||
#[stable(feature = "iterator_for_each", since = "1.22.0")]
|
||||
fn for_each<F>(self, mut f: F) where
|
||||
Self: Sized, F: FnMut(Self::Item),
|
||||
{
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 52d48656f93eeeb2c568e6c1048e64168e5b209f
|
||||
Subproject commit 7221e38023c41ff2532ebbf54a7da296fd488b50
|
Loading…
Reference in New Issue
Block a user