1 unstable release

0.1.0 Nov 22, 2024

#1862 in Rust patterns

Download history 19/week @ 2024-11-16 133/week @ 2024-11-23 19/week @ 2024-11-30 42/week @ 2024-12-07 37/week @ 2024-12-14 4/week @ 2024-12-21 2/week @ 2024-12-28 20/week @ 2025-01-04

63 downloads per month

MIT/Apache

3KB

Option macro

Sometimes you just need one little thing...

Intended to be used as a building block for other macros, specifically with macro repetitions. All it does is turning "nothing" into Option::None, and "something" (expr) into Option::Some(expr)

Example

macro_rules! readme {
    ($($input1:literal)?, $($input2:literal)?, $($input3:literal)?, $($input4:literal)?) => {
        (option!($($input1)?), option!($($input2)?), option!($($input3)?), option!($($input4)?))
    }
}

readme!(1, 2,  , 4) // (Some(1), Some(2), None, Some(4))

No runtime deps