pub struct Iso<S, T, A, B> { /* private fields */ }Expand description
An isomorphism witnesses that S and A are “the same” structure.
Only requires Profunctor — the weakest constraint of any optic.
S — source, T — modified source, A — focus, B — replacement.
Implementations§
Source§impl<S, T, A, B> Iso<S, T, A, B>
impl<S, T, A, B> Iso<S, T, A, B>
pub fn new(forward: fn(&S) -> A, backward: fn(B) -> T) -> Iso<S, T, A, B>
Source§impl<S, T, A, B> Iso<S, T, A, B>where
S: Clone,
impl<S, T, A, B> Iso<S, T, A, B>where
S: Clone,
Sourcepub fn to_lens(&self) -> ComposedLens<S, T, A, B>where
S: 'static,
T: 'static,
A: 'static,
B: 'static,
pub fn to_lens(&self) -> ComposedLens<S, T, A, B>where
S: 'static,
T: 'static,
A: 'static,
B: 'static,
Convert to a ComposedLens (uses boxed closures since iso’s backward
doesn’t match lens’s fn(S, B) -> T signature).
Sourcepub fn to_setter(&self) -> Setter<S, T, A, B>where
S: 'static,
T: 'static,
A: 'static,
B: 'static,
pub fn to_setter(&self) -> Setter<S, T, A, B>where
S: 'static,
T: 'static,
A: 'static,
B: 'static,
Convert to a Setter.
Sourcepub fn to_traversal(&self) -> Traversal<S, T, A, B>where
S: 'static,
T: 'static,
A: 'static,
B: 'static,
pub fn to_traversal(&self) -> Traversal<S, T, A, B>where
S: 'static,
T: 'static,
A: 'static,
B: 'static,
Convert to a Traversal (single-element).
Trait Implementations§
Auto Trait Implementations§
impl<S, T, A, B> Freeze for Iso<S, T, A, B>
impl<S, T, A, B> RefUnwindSafe for Iso<S, T, A, B>
impl<S, T, A, B> Send for Iso<S, T, A, B>
impl<S, T, A, B> Sync for Iso<S, T, A, B>
impl<S, T, A, B> Unpin for Iso<S, T, A, B>
impl<S, T, A, B> UnsafeUnpin for Iso<S, T, A, B>
impl<S, T, A, B> UnwindSafe for Iso<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