Files @ 1b7b852c3395
Branch filter:

Location: CSY/reowolf/src/macros.rs

1b7b852c3395 511 B application/rls-services+xml Show Annotation Show as Raw Download as Raw
Hans-Dieter Hiep
Add testdata
macro_rules! assert_let {
    ($pat:pat = $expr:expr => $work:expr) => {
        if let $pat = $expr {
            $work
        } else {
            panic!("assert_let failed");
        }
    };
}

#[test]
fn assert_let() {
    let x = Some(5);
    let z = assert_let![Some(y) = x => {
        println!("{:?}", y);
        3
    }];
    println!("{:?}", z);
}

#[test]
#[should_panic]
fn must_let_panic() {
    let x: Option<u32> = None;
    assert_let![Some(y) = x => {
        println!("{:?}", y);
    }];
}