Trait Lens
pub trait Lens:
'static
+ Copy
+ Debug
+ Hash {
type Source;
type Target;
// Required method
fn view<'a>(
&self,
source: &'a Self::Source,
) -> Option<LensValue<'a, Self::Target>>;
}
Expand description
A Lens allows the construction of a reference to a piece of some data, e.g. a field of a struct.
When deriving the Lens
trait on a struct, the derive macro constructs a static type which implements the Lens
trait for each field.
The view()
method takes a reference to the struct type as input and outputs a reference to the field.
This provides a way to specify a binding to a specific field of some application data.
Required Associated Types§
Required Methods§
Object Safety§
This trait is not object safe.