Crates.io | option_macro |
lib.rs | option_macro |
version | 0.1.0 |
source | src |
created_at | 2024-11-22 23:21:47.829002 |
updated_at | 2024-11-22 23:21:47.829002 |
description | a convenience macro |
homepage | |
repository | https://github.com/adsick/option_macro |
max_upload_size | |
id | 1457959 |
size | 2,120 |
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)
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))