#enums #unwrap #adt

no-std unwrap_to

A utility macro to unwrap enums

1 unstable release

Uses old Rust 2015

0.1.0 May 12, 2018

#1186 in Development tools

Download history 401/week @ 2024-03-14 537/week @ 2024-03-21 316/week @ 2024-03-28 537/week @ 2024-04-04 568/week @ 2024-04-11 535/week @ 2024-04-18 768/week @ 2024-04-25 567/week @ 2024-05-02 404/week @ 2024-05-09 680/week @ 2024-05-16 497/week @ 2024-05-23 583/week @ 2024-05-30 553/week @ 2024-06-06 518/week @ 2024-06-13 624/week @ 2024-06-20 402/week @ 2024-06-27

2,202 downloads per month
Used in 11 crates (5 directly)

MIT/Apache

3KB

unwrap_to

Build status

A simple utility macro that allows you to easily unwrap a ADT(Abstract Data Type) enum into a reference of its inner type.

#[macro_use] extern crate unwrap_to;
//!
enum Rule {
    String(String),
    Number(u64),
}
//!
fn main() {
    let rule = Rule::Number(7);
    assert_eq!(&7, unwrap_to!(rule => Rule::Number));
}

lib.rs:

unwrap_to

A simple utility macro that allows you to easily unwrap a ADT(Abstract Data Type) enum into a reference of its inner type.

#[macro_use] extern crate unwrap_to;

enum Rule {
    String(String),
    Number(u64),
}

fn main() {
    let rule = Rule::Number(7);
    assert_eq!(&7, unwrap_to!(rule => Rule::Number));
}

A simple utility macro that allows you to easily unwrap a ADT(Abstract Data Type) enum into a reference of its inner type.

No runtime deps