macro_rules! args {
($args:expr; $($rest:tt)*) => { ... };
(@next $args:ident, $i:ident,) => { ... };
(@next $args:ident, $i:ident, $name:ident : $ty:ty = $default:expr, $($rest:tt)*) => { ... };
(@next $args:ident, $i:ident, $name:ident : $ty:ty = $default:expr) => { ... };
(@next $args:ident, $i:ident, $name:ident : $ty:ty, $($rest:tt)*) => { ... };
(@next $args:ident, $i:ident, $name:ident : $ty:ty) => { ... };
}Expand description
Binds handler arguments to typed local variables.
Syntax: args! { <slice>; name: Type, name: Type = default, ... }.
Each variable consumes one positional argument, so the order matters. The trailing comma is allowed and optional.
ยงExample
โ
fn handler(_: &mut Engine, args: &[&str]) -> ErrorType {
args! { args;
count: u32,
label: String = "default".to_string(),
verbose: bool = false,
}
// ...
Ok(())
}