pub struct Lens<Root, Value> {
pub get: fn(&Root) -> &Value,
pub set: fn(&mut Root, Value),
}Expand description
A Lens represents a getter + setter for a field in Root.
Fields§
§get: fn(&Root) -> &Value§set: fn(&mut Root, Value)Implementations§
Source§impl<Root, Value> Lens<Root, Value>
impl<Root, Value> Lens<Root, Value>
pub fn new(get: fn(&Root) -> &Value, set: fn(&mut Root, Value)) -> Self
Sourcepub fn over(
&self,
update: impl Fn(Value) -> Value + 'static + Clone,
) -> impl Fn(Root) -> Root
pub fn over( &self, update: impl Fn(Value) -> Value + 'static + Clone, ) -> impl Fn(Root) -> Root
Immutable setter: like Swift prop(\.field)
Auto Trait Implementations§
impl<Root, Value> Freeze for Lens<Root, Value>
impl<Root, Value> RefUnwindSafe for Lens<Root, Value>
impl<Root, Value> Send for Lens<Root, Value>
impl<Root, Value> Sync for Lens<Root, Value>
impl<Root, Value> Unpin for Lens<Root, Value>
impl<Root, Value> UnwindSafe for Lens<Root, Value>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more