[−][src]Crate any_opt
This crate exports a macro to chain multiple options together to retrieve the first item that is Some
, from left to right
Every item is lazily evaluated, but to make this possible there's a caveat when trying to pass closures: you have to call them in place when passing the item
Example
fn my_fn<T>() -> Option<T> { None } fn main() { let opt = Some(3); let v = any_opt!((|| None)(), my_fn(), Some(13), Some(55), None, Some(42), opt).unwrap_or_default(); assert_eq!(v, 13); }
Macros
any_opt |