#sugar #unwrap #expressions #unwrapable

unwrap-sugar

Just a simple sugar for unwrapable expressions

2 releases

0.1.1 Jul 24, 2022
0.1.0 Jul 24, 2022

#18 in #sugar

23 downloads per month

MIT license

1MB
68 lines

unwrap-sugar

This just unwraps all expression in the macro simply.
The expressions must be unwrapable.

Usage

unwrap_sugar! {
    // Immutable
    a = Some('a');

    // Mutable
    mut b = Some('b');

    // Immutable with Type
    c:char = {
        Some('C').map(|x| x.to_ascii_lowercase())
    };
};

assert_eq!(a, 'a');
assert_eq!(b, 'b');
assert_eq!(c, 'c');

lib.rs:

Usage

This just unwraps all expression in the macro simply.
The expressions must be unwrapable.

unwrap_sugar! {
    // Immutable
    a = Some('a');

    // Mutable
    mut b = Some('b');

    // Immutable with Type
    c:char = {
        Some('C').map(|x| x.to_ascii_lowercase())
    };
};

assert_eq!(a, 'a');
assert_eq!(b, 'b');
assert_eq!(c, 'c');

No runtime deps