pub trait Iso<S, A>:
HasGetter<S, A, GetterError = Infallible>
+ HasSetter<S, A>
+ HasReverseGet<S, A, ReverseError = Infallible> { }Expand description
An Iso defines an isomorphism between two type, which is a bijective, reversible conversion between the members of two types.
It provides:
getto convert a value of typeSto typeAsetto change the value the optic operates onreverse_getto convert a value of typeAto typeS
This is useful when working with a data structure that can be represented in two different ways, such as a Point in XY coordinates and polar coordinates.
Type Arguments
S: The data type the optic operates onA: The data type the optic focuses on
§Note
This is a marker trait that is blanket implemented for all structs that satisfy the requirements.
§See Also
- [
FallibleIso] — a variant ofIsowhere the mapping might fail, returning an error IsoImpl— the wrapper of opaque struct that implement theIsotrait