Getter

Trait Getter 

Source
pub trait Getter<S, A>: HasGetter<S, A, GetterError = Infallible> { }
Expand description

A Getter is an optic that focuses on a value inside a product type.

It provides:

  • get to extract a focused value from a larger type

This is useful for working for example with required fields of a struct

Type Arguments:

  • S: The data type the optic operates on
  • A: 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

  • HasGetter - A base trait for optics that provides a partial getter operation.
  • [Lens] — an optic that focuses on an always-present value in a product type (e.g., a struct field)
  • [Iso] — an isomorphism optic representing a reversible one-to-one transformation between two types

Implementors§

Source§

impl<S, A, G: HasGetter<S, A, GetterError = Infallible>> Getter<S, A> for G