pub fn mapped_setter<S, A, SET>(
set_fn: SET,
) -> SetterImpl<S, A, impl Setter<S, A>>Expand description
Creates a new Setter with the provided setter function.
§Type Parameters
S: The source type of the opticA: The target type of the optic
§Arguments
set_fn— A function that sets the focus valueAfrom the sourceS.
§Returns
A new SetterImpl instance that can be used as a Setter<S, A>.
§Examples
use optics::{mapped_setter, HasSetter, Setter, SetterImpl};
struct Point { x: u32, y: u32 };
let mut s = Point { x: 1, y: 2 };
let setter = mapped_setter(|p: &mut Point, v| p.x = v);
setter.set(&mut s, 42);
assert_eq!(s.x, 42);