possibly 1.0.0

Like matches!(), but returning an Option type.
Documentation
1
2
3
4
5
6
7
8
9
#[macro_export]
macro_rules! possibly {
    ($expression:expr, $pattern:pat $(if $guard:expr)? => $returned:expr) => {
        match $expression {
            $pattern $(if $guard)? => Some($returned),
            _ => None
        }
    };
}