#downcast #match

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

#2714 in Rust patterns

Download history 21/week @ 2023-10-14 22/week @ 2023-10-21 23/week @ 2023-10-28 23/week @ 2023-11-04 22/week @ 2023-11-11 25/week @ 2023-11-18 28/week @ 2023-11-25 15/week @ 2023-12-02 17/week @ 2023-12-09 22/week @ 2023-12-16 27/week @ 2023-12-23 10/week @ 2023-12-30 17/week @ 2024-01-06 23/week @ 2024-01-13 22/week @ 2024-01-20 16/week @ 2024-01-27

83 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