writable_keypath

Macro writable_keypath 

Source
macro_rules! writable_keypath {
    ($closure:expr) => { ... };
}
Expand description

Macro to create a WritableKeyPath (writable, non-optional)

ยงExamples

use rust_keypaths::writable_keypath;
 
struct User { name: String, address: Address }
struct Address { street: String }
 
// Using a closure with type annotation
let kp = writable_keypath!(|u: &mut User| &mut u.name);
 
// Nested field access
let kp = writable_keypath!(|u: &mut User| &mut u.address.street);
 
// Or with automatic type inference
let kp = writable_keypath!(|u| &mut u.name);