diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /third_party/rust/scroll/src/error.rs | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | third_party/rust/scroll/src/error.rs | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/third_party/rust/scroll/src/error.rs b/third_party/rust/scroll/src/error.rs index 7740254774..1b68c2e4c7 100644 --- a/third_party/rust/scroll/src/error.rs +++ b/third_party/rust/scroll/src/error.rs @@ -1,10 +1,7 @@ use core::fmt::{self, Display}; use core::result; - -#[cfg(feature = "std")] -use std::error; #[cfg(feature = "std")] -use std::io; +use std::{error, io}; #[derive(Debug)] /// A custom Scroll error @@ -20,18 +17,19 @@ pub enum Error { size: usize, msg: &'static str, }, + /// A custom Scroll error for reporting messages to clients. + /// For no-std, use [`Error::BadInput`] with a static string. #[cfg(feature = "std")] - /// A custom Scroll error for reporting messages to clients Custom(String), - #[cfg(feature = "std")] /// Returned when IO based errors are encountered + #[cfg(feature = "std")] IO(io::Error), } #[cfg(feature = "std")] impl error::Error for Error { fn description(&self) -> &str { - match *self { + match self { Error::TooBig { .. } => "TooBig", Error::BadOffset(_) => "BadOffset", Error::BadInput { .. } => "BadInput", @@ -40,7 +38,7 @@ impl error::Error for Error { } } fn cause(&self) -> Option<&dyn error::Error> { - match *self { + match self { Error::TooBig { .. } => None, Error::BadOffset(_) => None, Error::BadInput { .. } => None, @@ -59,23 +57,23 @@ impl From<io::Error> for Error { impl Display for Error { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - match *self { + match self { Error::TooBig { ref size, ref len } => { - write!(fmt, "type is too big ({}) for {}", size, len) + write!(fmt, "type is too big ({size}) for {len}") } Error::BadOffset(ref offset) => { - write!(fmt, "bad offset {}", offset) + write!(fmt, "bad offset {offset}") } Error::BadInput { ref msg, ref size } => { - write!(fmt, "bad input {} ({})", msg, size) + write!(fmt, "bad input {msg} ({size})") } #[cfg(feature = "std")] Error::Custom(ref msg) => { - write!(fmt, "{}", msg) + write!(fmt, "{msg}") } #[cfg(feature = "std")] Error::IO(ref err) => { - write!(fmt, "{}", err) + write!(fmt, "{err}") } } } |