box Error container type

master
Avril 3 years ago
parent 5f57be3ed9
commit 3a3e66675c
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -54,10 +54,6 @@ pub struct Error(Box<ErrorKind>, bool);
impl Error impl Error
{ {
#[inline(always)] fn into_mode(self, encode: bool) -> Self
{
Self(self.0, encode)
}
/// An encode error /// An encode error
#[inline] pub fn encode(kind: impl Into<ErrorKind>) -> Self #[inline] pub fn encode(kind: impl Into<ErrorKind>) -> Self
{ {
@ -75,6 +71,12 @@ impl Error
&self.0 &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? /// Is an encode error?
#[inline] pub fn is_encode(&self) -> bool #[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 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
{ {
write!(f, "formatting error: ")?; write!(f, "formatting error in ")?;
if self.1 { if self.1 {
write!(f, "encode") write!(f, "encode")
} else { } else {

Loading…
Cancel
Save