[][src]Trait pl_lens::RefLens

pub trait RefLens: Lens {
    fn get_ref<'a>(&self, source: &'a Self::Source) -> &'a Self::Target;

    fn mutate_with_fn<'a>(
        &self,
        source: &'a mut Self::Source,
        f: &dyn Fn(&Self::Target) -> Self::Target
    ) { ... }
fn modify(
        &self,
        source: Self::Source,
        f: &dyn Fn(&Self::Target) -> Self::Target
    ) -> Self::Source { ... } }

A lens that allows the target to be accessed and mutated by reference.

Required methods

fn get_ref<'a>(&self, source: &'a Self::Source) -> &'a Self::Target

Gets a reference to the target of the lens. (This does not consume the source.)

Loading content...

Provided methods

fn mutate_with_fn<'a>(
    &self,
    source: &'a mut Self::Source,
    f: &dyn Fn(&Self::Target) -> Self::Target
)

Modifies the target of the lens by applying a function to the current value.

fn modify(
    &self,
    source: Self::Source,
    f: &dyn Fn(&Self::Target) -> Self::Target
) -> Self::Source

Modifies the target of the lens by applying a function to the current value. This consumes the source.

Loading content...

Implementations on Foreign Types

impl<L: RefLens + ?Sized> RefLens for Box<L>[src]

Loading content...

Implementors

impl<LHS, RHS> RefLens for ComposedLens<LHS, RHS> where
    LHS: RefLens,
    LHS::Target: 'static,
    RHS: RefLens<Source = LHS::Target>, 
[src]

Loading content...