Struct optics::concrete::MapFallible

source ·
pub struct MapFallible<L, F, G>(/* private fields */);
Expand description

Optics wrapper for mapping the Success and Error value.

Trait Implementations§

source§

impl<T, L: AffineFold<T>, S, F, E, G> AffineFold<T> for MapFallible<L, F, G>
where F: Fn(L::Success) -> S, G: Fn(L::Error) -> E, L::View: Sized,

source§

fn preview(&self, s: T) -> Result<Self::View, E>

Retrieve the value targeted by an AffineFold.
source§

impl<'a, T: ?Sized, L: AffineFoldMut<'a, T>, S, F, E, G> AffineFoldMut<'a, T> for MapFallible<L, F, G>
where F: Fn(L::Success) -> S, G: Fn(L::Error) -> E, L::View: 'a,

source§

fn preview_mut(&self, s: &'a mut T) -> Result<&'a mut Self::View, E>

Retrieve a mutable reference the value targeted by an AffineFold.
source§

impl<'a, T: ?Sized, L: AffineFoldRef<'a, T>, S, F, E, G> AffineFoldRef<'a, T> for MapFallible<L, F, G>
where F: Fn(L::Success) -> S, G: Fn(L::Error) -> E, L::View: 'a,

source§

fn preview_ref(&self, s: &'a T) -> Result<&'a Self::View, E>

Retrieve a shared reference the value targeted by an AffineFold.
source§

impl<T, L: AffineTraversal<T>, S, F, E, G> AffineTraversal<T> for MapFallible<L, F, G>
where F: Fn(L::Success) -> S, G: Fn(L::Error) -> E, L::View: Sized,

source§

fn map(&self, s: &mut T, f: impl FnOnce(&mut Self::View))

Restricted version for Setter::over. Custom implementation recommended.
source§

fn set(&self, s: &mut T, a: Self::View)

Apply a setter. No Clone is needed, because this optics is affine.
source§

impl<T, L: Getter<T>, S, F, E, G> Getter<T> for MapFallible<L, F, G>
where F: Fn(L::Success) -> S, G: Fn(L::Error) -> E, L::View: Sized,

source§

fn view(&self, s: T) -> Self::View

View the value pointed to by a getter.
source§

impl<'a, T: ?Sized, L: GetterMut<'a, T>, S, F, E, G> GetterMut<'a, T> for MapFallible<L, F, G>
where F: Fn(L::Success) -> S, G: Fn(L::Error) -> E, L::View: 'a,

source§

fn view_mut(&self, s: &'a mut T) -> &'a mut Self::View

Get a mutable reference to the value pointed to by a getter.
source§

impl<'a, T: ?Sized, L: GetterRef<'a, T>, S, F, E, G> GetterRef<'a, T> for MapFallible<L, F, G>
where F: Fn(L::Success) -> S, G: Fn(L::Error) -> E, L::View: 'a,

source§

fn view_ref(&self, s: &'a T) -> &'a Self::View

Get a shared reference to the value pointed to by a getter.
source§

impl<T: ?Sized, L: Optics<T>, F, G> Optics<T> for MapFallible<L, F, G>

§

type View = <L as Optics<T>>::View

View type for this optics.
source§

impl<L: OpticsFallible, S, F, E, G> OpticsFallible for MapFallible<L, F, G>
where F: Fn(L::Success) -> S, G: Fn(L::Error) -> E,

§

type Success = S

Success type for this optics.
§

type Error = E

Error type for this optics.
source§

fn success_witness(&self) -> S

Get a lightweight witness for success.
source§

fn map_fallible<S, F, E, G>(self, f: F, g: G) -> MapFallible<Self, F, G>
where Self: Sized, F: Fn(Self::Success) -> S, G: Fn(Self::Error) -> E,

Map the Success and Error type for this fallible optics.
source§

fn map_success<S, F>(self, f: F) -> MapSuccess<Self, F>
where Self: Sized, F: Fn(Self::Success) -> S,

Map the Success type for this fallible optics.
source§

fn map_error<E, G>(self, g: G) -> MapError<Self, G>
where Self: Sized, G: Fn(Self::Error) -> E,

Map the Error type for this fallible optics.
source§

impl<T, L: Review<T>, F, G> Review<T> for MapFallible<L, F, G>
where L::View: Sized,

source§

fn review(&self, a: Self::View) -> T

Retrieve the value targeted by a review.
source§

impl<T, L: Setter<T>, F, G> Setter<T> for MapFallible<L, F, G>
where L::View: Sized,

source§

fn over(&self, s: &mut T, f: &mut dyn FnMut(&mut Self::View))

Apply a setter as a modifier.
source§

fn set_cloned(&self, a: &Self::View, s: &mut T)
where Self::View: Clone,

Apply a setter. Read more
source§

impl<T, L: Traversal<T>, F, G> Traversal<T> for MapFallible<L, F, G>
where L::View: Sized,

source§

fn traverse(&self, s: T, f: &mut dyn FnMut(Self::View))

Evaluate the action from left to right on each element targeted by a Traversal.
source§

fn fold<C>(&self, s: T, init: C, f: impl FnMut(&mut C, Self::View)) -> C

Fold every element targeted by this Traversal into a single result.
source§

fn flatten(&self, s: T) -> Vec<Self::View>

Flatten the elements targeted by this Traversal into a Vec.
source§

impl<T, L: Iso<T>, S, F, E, G> Iso<T> for MapFallible<L, F, G>
where F: Fn(L::Success) -> S, G: Fn(L::Error) -> E, L::View: Sized,

source§

impl<T, L: Lens<T>, S, F, E, G> Lens<T> for MapFallible<L, F, G>
where F: Fn(L::Success) -> S, G: Fn(L::Error) -> E, L::View: Sized,

source§

impl<T, L: Prism<T>, S, F, E, G> Prism<T> for MapFallible<L, F, G>
where F: Fn(L::Success) -> S, G: Fn(L::Error) -> E, L::View: Sized,

Auto Trait Implementations§

§

impl<L, F, G> Freeze for MapFallible<L, F, G>
where L: Freeze, F: Freeze, G: Freeze,

§

impl<L, F, G> RefUnwindSafe for MapFallible<L, F, G>

§

impl<L, F, G> Send for MapFallible<L, F, G>
where L: Send, F: Send, G: Send,

§

impl<L, F, G> Sync for MapFallible<L, F, G>
where L: Sync, F: Sync, G: Sync,

§

impl<L, F, G> Unpin for MapFallible<L, F, G>
where L: Unpin, F: Unpin, G: Unpin,

§

impl<L, F, G> UnwindSafe for MapFallible<L, F, G>
where L: UnwindSafe, F: UnwindSafe, G: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.