fallthrough

Build Status API reference Crates.io License

This crate provides a fallthrough macro, which allows performing a pattern match with fallthrough through the arms, in the style of C switch.

```rust use fallthrough::fallthrough;

fn fall(scrutinee: u32) -> u32 { let mut ret: u32 = 0;

fallthrough!(scrutinee,
    val @ (0 | 63..) => ret = val + 7,
    'one: 1 => ret += 8,
    'two: 2 => ret += 9,
    'three: 3 if true => { ret += 10; break 'end },
    'four: 4 => ret = 42,
    'five: 5 => { ret += 1; break 'seven },
    'six: 6 => ret = 3,
    'seven: _ => ret *= 2,
    'end
);
ret

}

fn main() { asserteq!(fall(0), 34); asserteq!(fall(1), 27); asserteq!(fall(2), 19); asserteq!(fall(3), 10); asserteq!(fall(4), 86); asserteq!(fall(5), 2); asserteq!(fall(6), 6); asserteq!(fall(7), 0); assert_eq!(fall(64), 98); } ```