pub struct FnConverter<L, R, F, G, EL = Infallible, ER = Infallible> { /* private fields */ }Expand description
A converter that uses closures for conversions.
This is useful when you want to provide custom conversion logic without implementing the TryFrom trait.
Trait Implementations§
Source§impl<L, R, F, G, EL, ER> Clone for FnConverter<L, R, F, G, EL, ER>
impl<L, R, F, G, EL, ER> Clone for FnConverter<L, R, F, G, EL, ER>
Source§impl<L, R, F, G, EL, ER> Converter<L, R> for FnConverter<L, R, F, G, EL, ER>
impl<L, R, F, G, EL, ER> Converter<L, R> for FnConverter<L, R, F, G, EL, ER>
Source§type ToLeftError<'a> = EL
where
R: 'a
type ToLeftError<'a> = EL where R: 'a
The error type returned when converting from right to left.
Source§type ToRightError<'a> = ER
where
L: 'a
type ToRightError<'a> = ER where L: 'a
The error type returned when converting from left to right.
Source§fn convert_to_left<'a>(&self, right: &'a R) -> Result<L, Self::ToLeftError<'a>>
fn convert_to_left<'a>(&self, right: &'a R) -> Result<L, Self::ToLeftError<'a>>
Converts a reference to a right value into a left value.
Source§fn convert_to_right<'a>(&self, left: &'a L) -> Result<R, Self::ToRightError<'a>>
fn convert_to_right<'a>(&self, left: &'a L) -> Result<R, Self::ToRightError<'a>>
Converts a reference to a left value into a right value.
Auto Trait Implementations§
impl<L, R, F, G, EL, ER> Freeze for FnConverter<L, R, F, G, EL, ER>
impl<L, R, F, G, EL, ER> RefUnwindSafe for FnConverter<L, R, F, G, EL, ER>where
F: RefUnwindSafe,
G: RefUnwindSafe,
L: RefUnwindSafe,
R: RefUnwindSafe,
EL: RefUnwindSafe,
ER: RefUnwindSafe,
impl<L, R, F, G, EL, ER> Send for FnConverter<L, R, F, G, EL, ER>
impl<L, R, F, G, EL, ER> Sync for FnConverter<L, R, F, G, EL, ER>
impl<L, R, F, G, EL, ER> Unpin for FnConverter<L, R, F, G, EL, ER>
impl<L, R, F, G, EL, ER> UnwindSafe for FnConverter<L, R, F, G, EL, ER>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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