macro_rules! keypath {
($closure:expr) => { ... };
}Expand description
Macro to create a KeyPath (readable, non-optional)
ยงExamples
use rust_keypaths::keypath;
struct User { name: String, address: Address }
struct Address { street: String }
// Using a closure with type annotation
let kp = keypath!(|u: &User| &u.name);
// Nested field access
let kp = keypath!(|u: &User| &u.address.street);
// Or with automatic type inference
let kp = keypath!(|u| &u.name);