HasSetter

Trait HasSetter 

Source
pub trait HasSetter<S, A> {
    // Required method
    fn set(&self, source: &mut S, value: A);
}
Expand description

A base trait for optics that provides a setter operation.

This trait defines the ability to set a value of type A into a mutable source of type S. It serves as a foundational trait for constructing more complex optics like lenses and prisms.

§Implementors

Types that implement HasSetter can be used to define optics that allow for setting values into a source.

  • [Setter] — a concrete optic that allows only set operations.
  • [Prism] — optic that allows for fallible retrieval of values.
  • [Lens] — a total optic that allows for setting values.
  • [FallibleIso] — reversible optic that can allows for fallible conversion of values in both directions.///
  • [Iso] — a reversible optic that allows for setting values in both directions.

Required Methods§

Source

fn set(&self, source: &mut S, value: A)

Sets a value of type A the optic focuses on in a mutable source of type S.

§Parameters
  • source: A mutable reference to the source of type S into which the value is to be set.
  • value: The value of type A to be set into the source.

Implementors§

Source§

impl<S, A, FI: FallibleIso<S, A>> HasSetter<S, A> for FallibleIsoImpl<S, A, FI>

Source§

impl<S, A, ISO: Iso<S, A>> HasSetter<S, A> for IsoImpl<S, A, ISO>

Source§

impl<S, A, L: Lens<S, A>> HasSetter<S, A> for LensImpl<S, A, L>

Source§

impl<S, A, P: Prism<S, A>> HasSetter<S, A> for PrismImpl<S, A, P>

Source§

impl<S, A, SETTER: Setter<S, A>> HasSetter<S, A> for SetterImpl<S, A, SETTER>