diff options
author | David Tolnay <dtolnay@chromium.org> | 2019-03-01 18:07:56 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-03-02 17:41:31 -0800 |
commit | c69f97542a6071f78d48a743ee94119a93bc9471 (patch) | |
tree | 69ee27de806bf460c108219d9d2c64bd633cf35d /kernel_cmdline/src | |
parent | 5e1b46cbd8cb031a12c0fb20e94670f1007fd789 (diff) | |
download | crosvm-c69f97542a6071f78d48a743ee94119a93bc9471.tar crosvm-c69f97542a6071f78d48a743ee94119a93bc9471.tar.gz crosvm-c69f97542a6071f78d48a743ee94119a93bc9471.tar.bz2 crosvm-c69f97542a6071f78d48a743ee94119a93bc9471.tar.lz crosvm-c69f97542a6071f78d48a743ee94119a93bc9471.tar.xz crosvm-c69f97542a6071f78d48a743ee94119a93bc9471.tar.zst crosvm-c69f97542a6071f78d48a743ee94119a93bc9471.zip |
error: Consistently use Display instead of error description()
The description method is deprecated and its signature forces less helpful error messages than what Display can provide. BUG=none TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu Change-Id: I27fc99d59d0ef457c5273dc53e4c563ef439c2c0 Reviewed-on: https://chromium-review.googlesource.com/1497735 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'kernel_cmdline/src')
-rw-r--r-- | kernel_cmdline/src/kernel_cmdline.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/kernel_cmdline/src/kernel_cmdline.rs b/kernel_cmdline/src/kernel_cmdline.rs index 1e1870e..7284004 100644 --- a/kernel_cmdline/src/kernel_cmdline.rs +++ b/kernel_cmdline/src/kernel_cmdline.rs @@ -4,7 +4,7 @@ //! Helper for creating valid kernel command line strings. -use std::fmt; +use std::fmt::{self, Display}; use std::result; /// The error type for command line building operations. @@ -20,18 +20,18 @@ pub enum Error { TooLarge, } -impl fmt::Display for Error { +impl Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!( - f, - "{}", - match *self { - Error::InvalidAscii => "string contains non-printable ASCII character", - Error::HasSpace => "string contains a space", - Error::HasEquals => "string contains an equals sign", - Error::TooLarge => "inserting string would make command line too long", - } - ) + use self::Error::*; + + let description = match self { + InvalidAscii => "string contains non-printable ASCII character", + HasSpace => "string contains a space", + HasEquals => "string contains an equals sign", + TooLarge => "inserting string would make command line too long", + }; + + write!(f, "{}", description) } } |