pub fn mprop<Root, Value>(
keypath: WritableKeyPath<Root, Value>,
) -> impl Fn(Box<dyn FnMut(&mut Value)>) -> Box<dyn FnMut(&mut Root)>where
Root: 'static,
Value: 'static,Expand description
Produces an in-place setter function for a given key path. Useful for composing value property changes efficiently. Equivalent to Swift’s mprop<Root, Value>(_ keyPath: WritableKeyPath<Root, Value>) -> (@escaping (inout Value) -> Void) -> (inout Root) -> Void
§Examples
use overture_core::keypath::{WritableKeyPath, mprop};
let age_keypath = WritableKeyPath::new(
|person: &Person| person.age,
|person: &mut Person, age| person.age = age
);
let mut_update_age = mprop(age_keypath);
let mut double_age = mut_update_age(Box::new(|age| *age *= 2));
let mut person = Person { name: "Alice".to_string(), age: 30 };
double_age(&mut person);
assert_eq!(person.age, 60);