diff options
| author | T-O-R-U-S <bageliq@protonmail.com> | 2022-02-12 23:16:17 +0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-03-10 10:23:40 -0500 |
| commit | 72a25d05bf1a4b155d74139ef700ff93af6d8e22 (patch) | |
| tree | 3f143b29a3a51b68e9b29d93e47fb0b0968ad3df /library/core/src/iter/mod.rs | |
| parent | ba14a836c7038da21f5e102aacc7e6d5964f79a6 (diff) | |
| download | rust-72a25d05bf1a4b155d74139ef700ff93af6d8e22.tar.gz rust-72a25d05bf1a4b155d74139ef700ff93af6d8e22.zip | |
Use implicit capture syntax in format_args
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
Diffstat (limited to 'library/core/src/iter/mod.rs')
| -rw-r--r-- | library/core/src/iter/mod.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/library/core/src/iter/mod.rs b/library/core/src/iter/mod.rs index 65f56f64dbf..5a987733134 100644 --- a/library/core/src/iter/mod.rs +++ b/library/core/src/iter/mod.rs @@ -144,7 +144,7 @@ //! let values = vec![1, 2, 3, 4, 5]; //! //! for x in values { -//! println!("{}", x); +//! println!("{x}"); //! } //! ``` //! @@ -164,7 +164,7 @@ //! let values = vec![1, 2, 3, 4, 5]; //! //! for x in values { -//! println!("{}", x); +//! println!("{x}"); //! } //! ``` //! @@ -181,7 +181,7 @@ //! None => break, //! }; //! let x = next; -//! let () = { println!("{}", x); }; +//! let () = { println!("{x}"); }; //! }, //! }; //! result @@ -280,7 +280,7 @@ //! ``` //! # #![allow(unused_must_use)] //! let v = vec![1, 2, 3, 4, 5]; -//! v.iter().map(|x| println!("{}", x)); +//! v.iter().map(|x| println!("{x}")); //! ``` //! //! This will not print any values, as we only created an iterator, rather than @@ -297,10 +297,10 @@ //! ``` //! let v = vec![1, 2, 3, 4, 5]; //! -//! v.iter().for_each(|x| println!("{}", x)); +//! v.iter().for_each(|x| println!("{x}")); //! // or //! for x in &v { -//! println!("{}", x); +//! println!("{x}"); //! } //! ``` //! @@ -329,7 +329,7 @@ //! let five_numbers = numbers.take(5); //! //! for number in five_numbers { -//! println!("{}", number); +//! println!("{number}"); //! } //! ``` //! @@ -345,7 +345,7 @@ //! let ones = std::iter::repeat(1); //! let least = ones.min().unwrap(); // Oh no! An infinite loop! //! // `ones.min()` causes an infinite loop, so we won't reach this point! -//! println!("The smallest number one is {}.", least); +//! println!("The smallest number one is {least}."); //! ``` //! //! [`take`]: Iterator::take |
