#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

#1244 in Development tools

Download history 288/week @ 2024-07-21 565/week @ 2024-07-28 476/week @ 2024-08-04 357/week @ 2024-08-11 480/week @ 2024-08-18 506/week @ 2024-08-25 458/week @ 2024-09-01 509/week @ 2024-09-08 500/week @ 2024-09-15 700/week @ 2024-09-22 453/week @ 2024-09-29 506/week @ 2024-10-06 362/week @ 2024-10-13 450/week @ 2024-10-20 677/week @ 2024-10-27 470/week @ 2024-11-03

2,027 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