Skip to main content

get_or

Macro get_or 

Source
macro_rules! get_or {
    ($kp:expr, $root:expr, $default:expr) => { ... };
    ($root:expr => $($path:tt)*, $default:expr) => { ... };
}
Expand description

Get value through a keypath or a default reference when the path returns None. Use with KpType: get_or!(User::name(), &user, &default) where default is &T (same type as the path value). Returns &T. Path syntax: get_or!(&user => User.name, &default).