SetterImpl

Struct SetterImpl 

Source
pub struct SetterImpl<S, A, SETTER: Setter<S, A>>(pub SETTER, _);
Expand description

A wrapper of the Setter optic implementations, encapsulating a setter function.

SetterImpl provides a way to define setters - optics that are able to write to a focued value of type A from a source of type S. This struct is particularly useful in scenarios where you need to allow a callee to write into a struct without being able to read its contents.

§Note

This struct is not intended to be created by users directly, but it implements a From<Setter<S,A>> so that implementors of new optic types can wrap their concrete implementation of a Setter optic.

§Type Parameters

  • S: The source type from which the value is to be retrieved.
  • A: The target type of the value to be retrieved.

§See Also

  • Setter trait for defining custom partial getters.
  • [mapped_setter] function for creating SetterImpl instances from mapping functions.

Tuple Fields§

§0: SETTER

Trait Implementations§

Source§

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

Source§

fn from(value: SETTER) -> Self

Converts to this type from the input type.
Source§

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

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. Read more

Auto Trait Implementations§

§

impl<S, A, SETTER> Freeze for SetterImpl<S, A, SETTER>
where SETTER: Freeze,

§

impl<S, A, SETTER> RefUnwindSafe for SetterImpl<S, A, SETTER>

§

impl<S, A, SETTER> Send for SetterImpl<S, A, SETTER>
where SETTER: Send, S: Send, A: Send,

§

impl<S, A, SETTER> Sync for SetterImpl<S, A, SETTER>
where SETTER: Sync, S: Sync, A: Sync,

§

impl<S, A, SETTER> Unpin for SetterImpl<S, A, SETTER>
where SETTER: Unpin, S: Unpin, A: Unpin,

§

impl<S, A, SETTER> UnwindSafe for SetterImpl<S, A, SETTER>
where SETTER: UnwindSafe, S: UnwindSafe, A: 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>,

Source§

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>,

Source§

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.
Source§

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