Struct im::lens::GeneralLens
[−]
[src]
pub struct GeneralLens<From, To> { /* fields omitted */ }
An arbitrary non-partial lens defined by a pair of get and put functions.
Methods
impl<From, To> GeneralLens<From, To>
[src]
fn new(
get: Arc<Fn(&From) -> Arc<To>>,
put: Arc<Fn(&From, Arc<To>) -> From>
) -> GeneralLens<From, To>
get: Arc<Fn(&From) -> Arc<To>>,
put: Arc<Fn(&From, Arc<To>) -> From>
) -> GeneralLens<From, To>
Construct a lens from From
to To
from a pair of get and put functions.
Trait Implementations
impl<From, To> Clone for GeneralLens<From, To>
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<A, B> PartialLens for GeneralLens<A, B>
[src]
type From = A
type To = B
fn try_get(&self, s: &A) -> Option<Arc<B>>
Get the focus of the lens, if available.
fn try_put<Convert>(&self, v: Option<Convert>, s: &A) -> Option<A> where
Arc<B>: From<Convert>,
Arc<B>: From<Convert>,
Put a value into the lens, returning the updated From
value if the operation succeeded. Read more
fn try_chain<L, Next>(
&self,
next: &L
) -> Compose<Self::From, Self::To, Next, Self, L> where
L: PartialLens<From = Self::To, To = Next>,
&self,
next: &L
) -> Compose<Self::From, Self::To, Next, Self, L> where
L: PartialLens<From = Self::To, To = Next>,
Compose this lens with a lens from To
to a new type Next
, yielding a lens from From
to Next
. Read more
impl<A, B> Lens for GeneralLens<A, B>
[src]
fn get(&self, s: &A) -> Arc<B>
Get the focus of the lens.
fn put<Convert>(&self, v: Convert, s: &A) -> A where
Arc<B>: From<Convert>,
Arc<B>: From<Convert>,
Put a value into the lens, returning the updated From
value.
fn chain<L, Next>(
&self,
next: &L
) -> Compose<Self::From, Self::To, Next, Self, L> where
L: Lens<From = Self::To, To = Next>,
&self,
next: &L
) -> Compose<Self::From, Self::To, Next, Self, L> where
L: Lens<From = Self::To, To = Next>,
Compose this lens with a lens from To
to a new type Next
, yielding a lens from From
to Next
. Read more