pub trait Prism<S, A>: HasGetter<S, A> + HasSetter<S, A> { }Expand description
A Prism is an optic that focuses on a potentially missing value, such as a variant of a
sum type (enum).
It provides:
try_getto optionally extract a focus value from a larger typesetto set the focused value of a larger type
This is useful for working with enum variants, Option values, or
other sum types where a focus value might be absent.
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
- [
Getter] — an optic that focuses on a potentially missing value in a larger type - [
Setter] — an optic that can change its focused value - [
Lens] — an optic that focuses on an always-present value in a product type (e.g., a required struct field) - [
FallibleIso] — a variant ofIsowhere the mapping might fail, returning an error - [
Iso] — an isomorphism optic representing a reversible bijective conversion between two types