#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

#1197 in Development tools

Download history 238/week @ 2023-12-07 269/week @ 2023-12-14 145/week @ 2023-12-21 97/week @ 2023-12-28 220/week @ 2024-01-04 351/week @ 2024-01-11 388/week @ 2024-01-18 403/week @ 2024-01-25 737/week @ 2024-02-01 270/week @ 2024-02-08 367/week @ 2024-02-15 244/week @ 2024-02-22 525/week @ 2024-02-29 417/week @ 2024-03-07 401/week @ 2024-03-14 476/week @ 2024-03-21

1,878 downloads per month
Used in 12 crates (6 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