option_macro

Crates.iooption_macro
lib.rsoption_macro
version0.1.0
sourcesrc
created_at2024-11-22 23:21:47.829002
updated_at2024-11-22 23:21:47.829002
descriptiona convenience macro
homepage
repositoryhttps://github.com/adsick/option_macro
max_upload_size
id1457959
size2,120
Vadim (adsick)

documentation

README

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))
Commit count: 5

cargo fmt