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).
This commit is contained in:
parent
ba14a836c7
commit
72a25d05bf
177 changed files with 724 additions and 734 deletions
|
@ -607,7 +607,7 @@ mod prim_pointer {}
|
|||
///
|
||||
/// // This loop prints: 0 1 2
|
||||
/// for x in array {
|
||||
/// print!("{} ", x);
|
||||
/// print!("{x} ");
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
|
@ -646,19 +646,19 @@ mod prim_pointer {}
|
|||
/// // This creates a slice iterator, producing references to each value.
|
||||
/// for item in array.into_iter().enumerate() {
|
||||
/// let (i, x): (usize, &i32) = item;
|
||||
/// println!("array[{}] = {}", i, x);
|
||||
/// println!("array[{i}] = {x}");
|
||||
/// }
|
||||
///
|
||||
/// // The `array_into_iter` lint suggests this change for future compatibility:
|
||||
/// for item in array.iter().enumerate() {
|
||||
/// let (i, x): (usize, &i32) = item;
|
||||
/// println!("array[{}] = {}", i, x);
|
||||
/// println!("array[{i}] = {x}");
|
||||
/// }
|
||||
///
|
||||
/// // You can explicitly iterate an array by value using `IntoIterator::into_iter`
|
||||
/// for item in IntoIterator::into_iter(array).enumerate() {
|
||||
/// let (i, x): (usize, i32) = item;
|
||||
/// println!("array[{}] = {}", i, x);
|
||||
/// println!("array[{i}] = {x}");
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
|
@ -673,13 +673,13 @@ mod prim_pointer {}
|
|||
/// // This iterates by reference:
|
||||
/// for item in array.iter().enumerate() {
|
||||
/// let (i, x): (usize, &i32) = item;
|
||||
/// println!("array[{}] = {}", i, x);
|
||||
/// println!("array[{i}] = {x}");
|
||||
/// }
|
||||
///
|
||||
/// // This iterates by value:
|
||||
/// for item in array.into_iter().enumerate() {
|
||||
/// let (i, x): (usize, i32) = item;
|
||||
/// println!("array[{}] = {}", i, x);
|
||||
/// println!("array[{i}] = {x}");
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
|
@ -702,26 +702,26 @@ mod prim_pointer {}
|
|||
/// // This iterates by reference:
|
||||
/// for item in array.iter() {
|
||||
/// let x: &i32 = item;
|
||||
/// println!("{}", x);
|
||||
/// println!("{x}");
|
||||
/// }
|
||||
///
|
||||
/// // This iterates by value:
|
||||
/// for item in IntoIterator::into_iter(array) {
|
||||
/// let x: i32 = item;
|
||||
/// println!("{}", x);
|
||||
/// println!("{x}");
|
||||
/// }
|
||||
///
|
||||
/// // This iterates by value:
|
||||
/// for item in array {
|
||||
/// let x: i32 = item;
|
||||
/// println!("{}", x);
|
||||
/// println!("{x}");
|
||||
/// }
|
||||
///
|
||||
/// // IntoIter can also start a chain.
|
||||
/// // This iterates by value:
|
||||
/// for item in IntoIterator::into_iter(array).enumerate() {
|
||||
/// let (i, x): (usize, i32) = item;
|
||||
/// println!("array[{}] = {}", i, x);
|
||||
/// println!("array[{i}] = {x}");
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue