pub fn mut_set_ref<Root, Value>(
keypath: ReferenceWritableKeyPath<Root, Value>,
value: Value,
) -> impl Fn(Root)where
Root: 'static,
Value: Clone + 'static,Expand description
Produces a reference-mutable setter function for a given key path and new value. Equivalent to Swift’s mut<Root, Value>(_ keyPath: ReferenceWritableKeyPath<Root, Value>, _ value: Value) -> (Root) -> Void
§Examples
use overture_core::keypath::{ReferenceWritableKeyPath, mut_set_ref};
let name_keypath = ReferenceWritableKeyPath::new(
|person: &Person| person.name.clone(),
|person: &Person, name| { /* would modify in place for reference types */ }
);
let set_name_bob = mut_set_ref(name_keypath, "Bob".to_string());
let person = Person { name: "Alice".to_string(), age: 30 };
set_name_bob(person);