about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorT-O-R-U-S <bageliq@protonmail.com>2022-02-12 23:16:17 +0400
committerMark Rousskov <mark.simulacrum@gmail.com>2022-03-10 10:23:40 -0500
commit72a25d05bf1a4b155d74139ef700ff93af6d8e22 (patch)
tree3f143b29a3a51b68e9b29d93e47fb0b0968ad3df /src/doc
parentba14a836c7038da21f5e102aacc7e6d5964f79a6 (diff)
downloadrust-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 'src/doc')
-rw-r--r--src/doc/rustdoc/src/how-to-write-documentation.md2
-rw-r--r--src/doc/unstable-book/src/compiler-flags/sanitizer.md8
-rw-r--r--src/doc/unstable-book/src/language-features/box-patterns.md4
3 files changed, 7 insertions, 7 deletions
diff --git a/src/doc/rustdoc/src/how-to-write-documentation.md b/src/doc/rustdoc/src/how-to-write-documentation.md
index f89495cca3a..38fd1db5c21 100644
--- a/src/doc/rustdoc/src/how-to-write-documentation.md
+++ b/src/doc/rustdoc/src/how-to-write-documentation.md
@@ -126,7 +126,7 @@ use std::env;
 
 // Prints each argument on a separate line
 for argument in env::args() {
-    println!("{}", argument);
+    println!("{argument}");
 }
 ```
 
diff --git a/src/doc/unstable-book/src/compiler-flags/sanitizer.md b/src/doc/unstable-book/src/compiler-flags/sanitizer.md
index 457851b0cc7..735521e667c 100644
--- a/src/doc/unstable-book/src/compiler-flags/sanitizer.md
+++ b/src/doc/unstable-book/src/compiler-flags/sanitizer.md
@@ -240,7 +240,7 @@ fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 {
 fn main() {
     let answer = do_twice(add_one, 5);
 
-    println!("The answer is: {}", answer);
+    println!("The answer is: {answer}");
 
     println!("With CFI enabled, you should not see the next answer");
     let f: fn(i32) -> i32 = unsafe {
@@ -250,7 +250,7 @@ fn main() {
     };
     let next_answer = do_twice(f, 5);
 
-    println!("The next answer is: {}", next_answer);
+    println!("The next answer is: {next_answer}");
 }
 ```
 Fig. 1. Modified example from the [Advanced Functions and
@@ -303,14 +303,14 @@ fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 {
 fn main() {
     let answer = do_twice(add_one, 5);
 
-    println!("The answer is: {}", answer);
+    println!("The answer is: {answer}");
 
     println!("With CFI enabled, you should not see the next answer");
     let f: fn(i32) -> i32 =
         unsafe { mem::transmute::<*const u8, fn(i32) -> i32>(add_two as *const u8) };
     let next_answer = do_twice(f, 5);
 
-    println!("The next answer is: {}", next_answer);
+    println!("The next answer is: {next_answer}");
 }
 ```
 Fig. 4. Another modified example from the [Advanced Functions and
diff --git a/src/doc/unstable-book/src/language-features/box-patterns.md b/src/doc/unstable-book/src/language-features/box-patterns.md
index bf0819ec920..584f4295cba 100644
--- a/src/doc/unstable-book/src/language-features/box-patterns.md
+++ b/src/doc/unstable-book/src/language-features/box-patterns.md
@@ -18,10 +18,10 @@ fn main() {
     let b = Some(Box::new(5));
     match b {
         Some(box n) if n < 0 => {
-            println!("Box contains negative number {}", n);
+            println!("Box contains negative number {n}");
         },
         Some(box n) if n >= 0 => {
-            println!("Box contains non-negative number {}", n);
+            println!("Box contains non-negative number {n}");
         },
         None => {
             println!("No box");