Crates.io | match-downcast |
lib.rs | match-downcast |
version | 0.1.2 |
source | src |
created_at | 2017-09-10 22:32:44.061639 |
updated_at | 2017-09-11 10:20:20.998162 |
description | A set of downcasting matching Rust macros. |
homepage | https://github.com/fst3a/match-downcast |
repository | https://github.com/fst3a/match-downcast |
max_upload_size | |
id | 31333 |
size | 8,996 |
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);