#downcast #matching #match #macro

no-std match-downcast

A set of downcasting matching Rust macros

2 releases

Uses old Rust 2015

0.1.2 Sep 11, 2017
0.1.1 Sep 10, 2017

#21 in #downcast

Download history 11/week @ 2024-02-19 29/week @ 2024-02-26 16/week @ 2024-03-04 13/week @ 2024-03-11 8/week @ 2024-03-18 14/week @ 2024-03-25 64/week @ 2024-04-01

102 downloads per month
Used in 2 crates

Unlicense

8KB
160 lines

Set of downcasting matching macros akin to what Scala's match or Haskell's case can do. Useful in actor models etc.

let a = Box::new(5_i32) as Box<Any>;
let b = match_downcast!(a, {
    x: i32 => x
    y: f32 => x as i32,
    z: () => -1,
    _ => panic!()
});

assert_eq!(b, 5);

No runtime deps