pub struct FnConverter<F, G> { /* 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<F: Clone, G: Clone> Clone for FnConverter<F, G>
impl<F: Clone, G: Clone> Clone for FnConverter<F, G>
Source§fn clone(&self) -> FnConverter<F, G>
fn clone(&self) -> FnConverter<F, G>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<L, R, F, G, EL, ER> Converter<L, R> for FnConverter<F, G>
impl<L, R, F, G, EL, ER> Converter<L, R> for FnConverter<F, G>
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<F, G> Freeze for FnConverter<F, G>
impl<F, G> RefUnwindSafe for FnConverter<F, G>where
F: RefUnwindSafe,
G: RefUnwindSafe,
impl<F, G> Send for FnConverter<F, G>
impl<F, G> Sync for FnConverter<F, G>
impl<F, G> Unpin for FnConverter<F, G>
impl<F, G> UnwindSafe for FnConverter<F, G>where
F: UnwindSafe,
G: 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> 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