1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//! Utility functions/macros

/// Shortcut for
/// ```no_compile
/// if let Some(thing) = optional_thing {
///     thing.<whatever>
/// }
/// ```
/// ```no_compile
/// if_some!(optional_thing, <whatever>);
/// ```
#[macro_export]
macro_rules! if_some {
    ( $option:ident, $($function:tt)* ) => {{
        if let Some(thing) = &$option {
            thing.$($function)*
        }
    }};
}