pub struct IsoImpl<S, A, ISO: Iso<S, A>>(pub ISO, _);Expand description
A wrapper of the Iso optic implementations, encapsulating a reversible bijective conversion.
IsoImpl provides a way to define a reversible bijective conversion - optics that can be used to
convert between values of type A and of type S.
This struct is particularly useful in scenarios where you need to deal with data types that have
multiple representations, such as a Point in cartesian and polar coordinates.
§Note
This struct is not intended to be created by users directly, but it implements a From<Iso<S,A>> so that implementors of new optic types can wrap their concrete implementation of an Iso optic.
§Type Parameters
S: The type the optic converts fromA: The type the optic converts to
§See Also
Isotrait for defining bijective conversions.- [
mapped_iso] function for creatingIsoImplinstances from mapping functions.
Tuple Fields§
§0: ISOImplementations§
Source§impl<S, I, ISO1: Iso<S, I>> IsoImpl<S, I, ISO1>
impl<S, I, ISO1: Iso<S, I>> IsoImpl<S, I, ISO1>
Sourcepub fn compose_with_partial_getter<A, PG2: PartialGetter<I, A>>(
self,
other: PartialGetterImpl<I, A, PG2>,
) -> PartialGetterImpl<S, A, impl PartialGetter<S, A, GetterError = PG2::GetterError>>
pub fn compose_with_partial_getter<A, PG2: PartialGetter<I, A>>( self, other: PartialGetterImpl<I, A, PG2>, ) -> PartialGetterImpl<S, A, impl PartialGetter<S, A, GetterError = PG2::GetterError>>
Composes this IsoImpl<S,I> with a PartialGetter<I,A>, resulting in a new PartialGetter<S, A>
that focuses through both optics sequentially.
The resulting PartialGetterImpl will attempt to extract a value by first applying self and then
other. If the second optic fails to focus, the composition will fail to focus.
§Type Parameters
A: The target type of the composed optic.PG2: The type of the partial getter to compose with.
§Parameters
other: The partial getter to compose with.
§Returns
A new PartialGetterImpl that represents the composition of self and other.
Sourcepub fn compose_with_getter<A, G2: Getter<I, A>>(
self,
other: GetterImpl<I, A, G2>,
) -> GetterImpl<S, A, impl Getter<S, A>>
pub fn compose_with_getter<A, G2: Getter<I, A>>( self, other: GetterImpl<I, A, G2>, ) -> GetterImpl<S, A, impl Getter<S, A>>
Composes this IsoImpl<S,I> with a GetterImpl<I,A>, resulting in a new GetterImpl<S, A>
that focuses through both optics sequentially.
The resulting GetterImpl will extract a value by first applying self and then
other.
§Type Parameters
A: The target type of the composed optic.G2: The type of the partial getter to compose with.
§Parameters
other: The getter to compose with.
§Returns
A new GetterImpl that represents the composition of self and other.
Sourcepub fn compose_with_setter<A, S2: Setter<I, A>>(
self,
other: SetterImpl<I, A, S2>,
) -> SetterImpl<S, A, impl Setter<S, A>>
pub fn compose_with_setter<A, S2: Setter<I, A>>( self, other: SetterImpl<I, A, S2>, ) -> SetterImpl<S, A, impl Setter<S, A>>
Composes this IsoImpl<S,I> with a Setter<I,A>, resulting in a new Setter<S, A>
that focuses through both optics sequentially.
The resulting SetterImpl will attempt to set a value by first applying self and then
other.
§Type Parameters
A: The target type of the composed optic.S2: The type of the setter to compose with.
§Parameters
other: The setter to compose with.
§Returns
A new SetterImpl that represents the composition of self and other.
Sourcepub fn compose_with_lens<A, L2: Lens<I, A>>(
self,
other: LensImpl<I, A, L2>,
) -> LensImpl<S, A, impl Lens<S, A>>
pub fn compose_with_lens<A, L2: Lens<I, A>>( self, other: LensImpl<I, A, L2>, ) -> LensImpl<S, A, impl Lens<S, A>>
Composes this IsoImpl<S,I> with a LensImpl<I,A>, resulting in a new LensImpl<S, A>
that focuses through both optics sequentially.
The resulting LensImpl will extract a value by first applying self and then
other.
§Type Parameters
A: The target type of the composed lens.L2: The type of the lens to compose with.
§Parameters
other: The lens to compose with.
§Returns
A new LensImpl that represents the composition of self and other
Sourcepub fn compose_with_prism<A, P2: Prism<I, A>>(
self,
other: PrismImpl<I, A, P2>,
) -> PrismImpl<S, A, impl Prism<S, A, GetterError = P2::GetterError>>
pub fn compose_with_prism<A, P2: Prism<I, A>>( self, other: PrismImpl<I, A, P2>, ) -> PrismImpl<S, A, impl Prism<S, A, GetterError = P2::GetterError>>
Composes this IsoImpl<S,I> with a Prism<I,A>, resulting in a new PrismImpl<S, A>
that focuses through both prisms sequentially.
The resulting PrismImpl will attempt to extract a value by first applying self and then
other. If the prism fails to focus, the composition will fail.
§Type Parameters
A: The target type of the composed prism.P2: The type of the prism to compose with.
§Parameters
other: The prism to compose with.
§Returns
A new PrismImpl that represents the composition of self and other.
Sourcepub fn compose_with_fallible_iso<A, FI2: FallibleIso<I, A>>(
self,
other: FallibleIsoImpl<I, A, FI2>,
) -> FallibleIsoImpl<S, A, impl FallibleIso<S, A, GetterError = FI2::GetterError, ReverseError = FI2::ReverseError>>
pub fn compose_with_fallible_iso<A, FI2: FallibleIso<I, A>>( self, other: FallibleIsoImpl<I, A, FI2>, ) -> FallibleIsoImpl<S, A, impl FallibleIso<S, A, GetterError = FI2::GetterError, ReverseError = FI2::ReverseError>>
Composes this IsoImpl<S,I> with a FallibleIso<I,A>, resulting in a new FallibleIsoImpl<S, A>
that focuses through both prisms sequentially.
The resulting FallibleIsoImpl will attempt to extract a value by first applying self and then
other. If the fallible iso fails to focus, the composition will fail to focus.
§Type Parameters
A: The target type of the composed prism.FI2: The type of the fallible iso to compose with.
§Parameters
other: The fallible iso to compose with.
§Returns
A new FallibleIsoImpl that represents the composition of self and other.
Sourcepub fn compose_with_iso<A, ISO2: Iso<I, A>>(
self,
other: IsoImpl<I, A, ISO2>,
) -> IsoImpl<S, A, impl Iso<S, A>>
pub fn compose_with_iso<A, ISO2: Iso<I, A>>( self, other: IsoImpl<I, A, ISO2>, ) -> IsoImpl<S, A, impl Iso<S, A>>
Composes this IsoImpl<S,I> with an IsoImpl<I,A>, resulting in a new IsoImpl<S, A>
that focuses through both optics sequentially.
The resulting IsoImpl will extract a value by first applying self and then
other.
§Type Parameters
A: The target type of the composed lens.ISO2: The type of the lens to compose with.
§Parameters
other: The iso to compose with.
§Returns
A new IsoImpl that represents the composition of self and other
Trait Implementations§
Source§impl<S, A, ISO: Iso<S, A>> HasGetter<S, A> for IsoImpl<S, A, ISO>
impl<S, A, ISO: Iso<S, A>> HasGetter<S, A> for IsoImpl<S, A, ISO>
Source§type GetterError = Infallible
type GetterError = Infallible
Infallible for infallible optics.Source§impl<S, A, ISO: Iso<S, A>> HasReverseGet<S, A> for IsoImpl<S, A, ISO>
impl<S, A, ISO: Iso<S, A>> HasReverseGet<S, A> for IsoImpl<S, A, ISO>
Source§type ReverseError = Infallible
type ReverseError = Infallible
Infallible for infallible optics.