Crates.io | variadiz-macros |
lib.rs | variadiz-macros |
version | 1.1.0 |
source | src |
created_at | 2024-04-29 06:17:39.375336 |
updated_at | 2024-05-10 08:45:27.355321 |
description | Procedural macros implementation of variadiz |
homepage | |
repository | https://github.com/NichtsHsu/variadiz |
max_upload_size | |
id | 1223868 |
size | 33,239 |
Variadic function support for Rust.
cargo add tuplez variadiz
use variadiz::*;
#[variadic]
fn print<T, U>(mut counter: usize, non_variadic: T, others: Option<U>)
where
T: std::fmt::Display,
U: std::fmt::Debug,
{
#[va_expand_ref(mut counter: usize)]
{
println!("{counter}: {:?}", others);
*counter += 1;
}
#[va_expand_mut]
{
others.take();
}
#[va_expand(mut counter: usize, non_variadic: T)]
{
println!("[{non_variadic}] {counter}: {:?}", others);
*counter += 1;
}
}
print(
0,
20240429,
va_args!(Some("hello"), Some(vec![1, 2, 3]), Some('e')),
);
Outputs:
0: Some("hello")
1: Some([1, 2, 3])
2: Some('e')
[20240429] 3: None
[20240429] 4: None
[20240429] 5: None
Check the documentation page for details.