From 3a3e66675c84f486ea2c03b9aa06a0f729645022 Mon Sep 17 00:00:00 2001 From: Avril Date: Fri, 28 May 2021 17:22:40 +0100 Subject: [PATCH] box Error container type --- src/formats/error.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/formats/error.rs b/src/formats/error.rs index 2388498..2bd4b84 100644 --- a/src/formats/error.rs +++ b/src/formats/error.rs @@ -54,10 +54,6 @@ pub struct Error(Box, bool); impl Error { - #[inline(always)] fn into_mode(self, encode: bool) -> Self - { - Self(self.0, encode) - } /// An encode error #[inline] pub fn encode(kind: impl Into) -> Self { @@ -75,6 +71,12 @@ impl Error &self.0 } + /// Consume into the kind of error, which contains the original error object from the conversion (if there is one) + #[inline] pub fn into_inner(self) -> ErrorKind + { + *self.0 + } + /// Is an encode error? #[inline] pub fn is_encode(&self) -> bool { @@ -105,7 +107,7 @@ impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "formatting error: ")?; + write!(f, "formatting error in ")?; if self.1 { write!(f, "encode") } else {