macro_rules! get_or_else {
($kp:expr, $root:expr, $closure:expr) => { ... };
($root:expr => ($($path:tt)*), $closure:expr) => { ... };
}Expand description
Get value through a keypath, or compute an owned fallback when the path returns None.
Use with KpType: get_or_else!(User::name(), &user, || "default".to_string()).
Returns T (owned). The keypath’s value type must be Clone. The closure is only called when the path is None.
Path syntax: get_or_else!(&user => (User.name), || "default".to_string()) — path in parentheses.