koption_macros

Some macros that are useful for working with Options.

There is at least one more thing planned as soon as I can figure out how to use proc_macros.

Examples

Straight from the unit tests.

```rust

[test]

fn orworks() { asserteq!(Some(1), or!(Some(1) => Some(2) => Some(3))); asserteq!(Some(2), or!(None => Some(2) => Some(3))); asserteq!(Some(3), or!(None => None => Some(3))); assert_eq!(None::<()>, or!(None => None => None)); }

[test]

fn andworks() { asserteq!(Some((1, 2, 3)), and!(Some(1) => Some(2) => Some(3))); asserteq!(None, and!(None => Some(2) => Some(3))); asserteq!(None, and!(None => None => Some(3))); assert_eq!(None, and!(None => None => None)); }

struct Config { log: Option, }

struct LogConfig { level: Option, }

[test]

fn tryworks() { asserteq!( Some(6), try_! { let x = Some(3); let y = Some(2); x? * y? } );

let config = Config {
    log: Some(LogConfig {
        level: Some("debug".to_owned()),
    }),
};

let x = try_! { config.log?.level? }.unwrap_or("foo".to_owned());
assert_eq!(x, "debug");

} ```

Why koption_macros?

It's my version of namespacing my crates with my last initial, k.