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)>
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()
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
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