[enumx 0.3.1] [cex 0.4.0] type as pattern matching for anonymous enums

The enumx crate has been upgraded to version 0.3.1 to support "type as pattern matching" feature for anonymous enums.

use enumx::*;

fn foo() -> Enum!( String, &'static str, Option<i32> );

#[enumx]
fn bar() {
    #[ty_pat] match foo() {
        Option::<i32>( i ) => (),
        String( s ) => (),
        TyPat::<&'static str>( s ) => (),
    }
}

The cex crate has been upgraded to version 0.4.0 to support this feature too.

And more macros Result!(), ret!(), and throw!() added for emulating checked exception:

struct SomeError;

#[cex] fn foo() -> Result!( i32 throws String, &'static str, SomeError ) {/**/}

#[cex] fn bar() {
    let _f = #[cex] || -> Result!( i32 throws String ) {/**/}
}

#[cex] fn baz() {
    #[cex] let v: Result!( i32 throws String ) = try {/**/};
}
1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.