New match_cast crate

I've created match_cast crate
I think it will be useful for Some + Any + trait geeks :slight_smile:

Example 1:

match_cast!( any {
    val as Option<u8> => {
        format!("Option<u8> = {:?}", val)
    },
    val as String => {
        format!("String = {:?}", val)
    },
    val as &'static str => {
        format!("&'static str = {:?}", val)
    },
});

Example 2:

struct Bar {
    x: u8,
}

struct Foo {
    x: u8,
}

match_down!( any {
    Bar { x } => { x },
    Foo { x } => { x },
});
}

It's good to check or destruct panics, dynamic objects, etc.

3 Likes