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/std/src/io/error.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/std/src/io/error.rs')
| -rw-r--r-- | library/std/src/io/error.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 17e2b97545a..4a50e647c64 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -457,7 +457,7 @@ impl From<ErrorKind> for Error { /// /// let not_found = ErrorKind::NotFound; /// let error = Error::from(not_found); - /// assert_eq!("entity not found", format!("{}", error)); + /// assert_eq!("entity not found", format!("{error}")); /// ``` #[inline] fn from(kind: ErrorKind) -> Error { @@ -561,7 +561,7 @@ impl Error { /// use std::io::Error; /// /// let os_error = Error::last_os_error(); - /// println!("last OS error: {:?}", os_error); + /// println!("last OS error: {os_error:?}"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[must_use] @@ -618,7 +618,7 @@ impl Error { /// /// fn print_os_error(err: &Error) { /// if let Some(raw_os_err) = err.raw_os_error() { - /// println!("raw OS error: {:?}", raw_os_err); + /// println!("raw OS error: {raw_os_err:?}"); /// } else { /// println!("Not an OS error"); /// } @@ -657,7 +657,7 @@ impl Error { /// /// fn print_error(err: &Error) { /// if let Some(inner_err) = err.get_ref() { - /// println!("Inner error: {:?}", inner_err); + /// println!("Inner error: {inner_err:?}"); /// } else { /// println!("No inner error"); /// } @@ -731,7 +731,7 @@ impl Error { /// /// fn print_error(err: &Error) { /// if let Some(inner_err) = err.get_ref() { - /// println!("Inner error: {}", inner_err); + /// println!("Inner error: {inner_err}"); /// } else { /// println!("No inner error"); /// } @@ -770,7 +770,7 @@ impl Error { /// /// fn print_error(err: Error) { /// if let Some(inner_err) = err.into_inner() { - /// println!("Inner error: {}", inner_err); + /// println!("Inner error: {inner_err}"); /// } else { /// println!("No inner error"); /// } @@ -852,7 +852,7 @@ impl fmt::Display for Error { match self.repr.data() { ErrorData::Os(code) => { let detail = sys::os::error_string(code); - write!(fmt, "{} (os error {})", detail, code) + write!(fmt, "{detail} (os error {code})") } ErrorData::Custom(ref c) => c.error.fmt(fmt), ErrorData::Simple(kind) => write!(fmt, "{}", kind.as_str()), |
