Struct wagon_utils::ConversionError
source · pub struct ConversionError<T, U> { /* private fields */ }
Expand description
We failed to convert from some thing to another thing.
A generic error for when doing any TryFrom
type implementations.
§Example
use wagon_utils::ConversionError;
struct A;
impl TryFrom<i32> for A {
type Error = ConversionError<i32, Self>;
fn try_from(value: i32) -> Result<Self, Self::Error> {
Err(ConversionError::new(value))
}
}
Implementations§
source§impl<T, U> ConversionError<T, U>
impl<T, U> ConversionError<T, U>
sourcepub fn convert<V: From<U>>(self) -> ConversionError<T, V>
pub fn convert<V: From<U>>(self) -> ConversionError<T, V>
Convert one implementation of ConversionError
to another.
More specifically, if we have a type V
which implements From<U>
, we can
construct a new ConversionError<T,V>
.
This exists for the case “We tried converting T to U, but actually we were converting T to V in this case”.
Because specialization is still not stabilized, this can not be done by a generic implementation of From
.
Trait Implementations§
source§impl<T: Display, U> Display for ConversionError<T, U>
impl<T: Display, U> Display for ConversionError<T, U>
source§impl<T: Display + Debug, U: Debug> Error for ConversionError<T, U>
impl<T: Display + Debug, U: Debug> Error for ConversionError<T, U>
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
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()
Auto Trait Implementations§
impl<T, U> Freeze for ConversionError<T, U>where
T: Freeze,
impl<T, U> RefUnwindSafe for ConversionError<T, U>where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for ConversionError<T, U>
impl<T, U> Sync for ConversionError<T, U>
impl<T, U> Unpin for ConversionError<T, U>
impl<T, U> UnwindSafe for ConversionError<T, U>where
T: UnwindSafe,
U: UnwindSafe,
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