pub fn mut_set_ref<Root, Value>(
keypath: KeyPaths<Root, Value>,
value: Value,
) -> impl Fn(Root)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 rust_overture::keypaths::mut_set_ref;
use key_paths_core::KeyPaths;
#[derive(Clone)]
struct Person {
name: String,
age: u32,
}
let name_keypath = KeyPaths::writable(|person: &mut Person| &mut person.name);
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);