pub fn mver_object<Root, Value>(
keypath: ReferenceWritableKeyPath<Root, Value>,
update: impl Fn(Value) + 'static,
) -> impl Fn(Root)where
Root: 'static,
Value: 'static,Expand description
Uncurried mver. Takes a key path and update function all at once.
Equivalent to Swift’s mverObject<Root, Value>(_ keyPath: ReferenceWritableKeyPath<Root, Value>, _ update: @escaping (Value) -> Void) -> (Root) -> Void where Value: AnyObject
§Examples
use overture_core::keypath::{ReferenceWritableKeyPath, mver_object};
let name_keypath = ReferenceWritableKeyPath::new(
|person: &Person| person.name.clone(),
|person: &Person, name| { /* would modify in place for reference types */ }
);
let uppercase_name = mver_object(name_keypath, |name| name.make_ascii_uppercase());
let person = Person { name: "alice".to_string(), age: 30 };
uppercase_name(person);