pub struct TypeErasedError { /* private fields */ }
Expand description
A new-type around Box<dyn Error + Debug + Send + Sync>
that also implements Error
Implementations§
source§impl TypeErasedError
impl TypeErasedError
sourcepub fn new<T: StdError + Send + Sync + Debug + 'static>(value: T) -> Self
pub fn new<T: StdError + Send + Sync + Debug + 'static>(value: T) -> Self
Create a new TypeErasedError
from value
of type T
sourcepub fn downcast<T: StdError + Debug + Send + Sync + 'static>(
self,
) -> Result<Box<T>, Self>
pub fn downcast<T: StdError + Debug + Send + Sync + 'static>( self, ) -> Result<Box<T>, Self>
Downcast into a Box<T>
, or return Self
if it is not a T
.
sourcepub fn downcast_ref<T: StdError + Debug + Send + Sync + 'static>(
&self,
) -> Option<&T>
pub fn downcast_ref<T: StdError + Debug + Send + Sync + 'static>( &self, ) -> Option<&T>
Downcast as a &T
, or return None
if it is not a T
.
sourcepub fn downcast_mut<T: StdError + Debug + Send + Sync + 'static>(
&mut self,
) -> Option<&mut T>
pub fn downcast_mut<T: StdError + Debug + Send + Sync + 'static>( &mut self, ) -> Option<&mut T>
Downcast as a &mut T
, or return None
if it is not a T
.
sourcepub fn doesnt_matter() -> Self
pub fn doesnt_matter() -> Self
Returns a TypeErasedError
with a fake/test value with the expectation that it won’t be downcast in the test.
Trait Implementations§
source§impl Debug for TypeErasedError
impl Debug for TypeErasedError
source§impl Display for TypeErasedError
impl Display for TypeErasedError
source§impl Error for TypeErasedError
impl Error for TypeErasedError
source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl From<TypeErasedError> for TypeErasedBox
impl From<TypeErasedError> for TypeErasedBox
source§fn from(value: TypeErasedError) -> Self
fn from(value: TypeErasedError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for TypeErasedError
impl !RefUnwindSafe for TypeErasedError
impl Send for TypeErasedError
impl Sync for TypeErasedError
impl Unpin for TypeErasedError
impl !UnwindSafe for TypeErasedError
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more