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>
impl<S, T, A, B> Traversal<S, T, A, B>
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>
pub fn get_all(&self, s: &S) -> Vec<A>
pub fn over(&self, s: S, f: impl Fn(A) -> B) -> T
pub fn set(&self, s: S, b: B) -> Twhere
B: Clone,
Sourcepub 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,
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.
Sourcepub fn to_fold(&self) -> Fold<S, A>where
S: 'static,
A: 'static,
pub fn to_fold(&self) -> Fold<S, A>where
S: 'static,
A: 'static,
Convert to a Fold (read-only).
Sourcepub 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,
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more