Skip to main content

Traversal

Struct Traversal 

Source
pub struct Traversal<S, T, A, B> { /* private fields */ }
Expand description

A multi-focus optic that can get/modify zero or more foci.

S — source, T — modified source, A — focus, B — replacement.

Implementations§

Source§

impl<S, T, A, B> Traversal<S, T, A, B>

Source

pub fn new( get_all: impl Fn(&S) -> Vec<A> + 'static, modify_all: impl Fn(S, &dyn Fn(A) -> B) -> T + 'static, ) -> Traversal<S, T, A, B>

Source

pub fn get_all(&self, s: &S) -> Vec<A>

Source

pub fn over(&self, s: S, f: impl Fn(A) -> B) -> T

Source

pub fn set(&self, s: S, b: B) -> T
where B: Clone,

Source

pub fn transform<P>(&self, pab: <P as HKT2>::P<A, B>) -> <P as HKT2>::P<S, T>
where P: Traversing, S: 'static, T: 'static, A: 'static, B: 'static,

Profunctor encoding via Traversing::wander.

Source

pub fn to_fold(&self) -> Fold<S, A>
where S: 'static, A: 'static,

Convert to a Fold (read-only).

Source

pub fn then<X, Y>( self, inner: Traversal<A, B, X, Y>, ) -> ComposedTraversal<S, T, X, Y>
where S: 'static, T: 'static, A: 'static, B: 'static, X: 'static, Y: 'static,

Compose with another traversal for deeper multi-focus access.

Trait Implementations§

Source§

impl<S, T, A, B> Optic for Traversal<S, T, A, B>

Auto Trait Implementations§

§

impl<S, T, A, B> !RefUnwindSafe for Traversal<S, T, A, B>

§

impl<S, T, A, B> !Send for Traversal<S, T, A, B>

§

impl<S, T, A, B> !Sync for Traversal<S, T, A, B>

§

impl<S, T, A, B> !UnwindSafe for Traversal<S, T, A, B>

§

impl<S, T, A, B> Freeze for Traversal<S, T, A, B>

§

impl<S, T, A, B> Unpin for Traversal<S, T, A, B>

§

impl<S, T, A, B> UnsafeUnpin for Traversal<S, T, A, B>

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.