match-downcast 0.1.2

A set of downcasting matching Rust macros.
Documentation
  • Coverage
  • 0%
    0 out of 4 items documented0 out of 0 items with examples
  • Size
  • Source code size: 8.63 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 627.28 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • fst3a

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);