validator

Macro validator 

Source
macro_rules! validator {
    ($($type:ty),*) => { ... };
    (@replace $_old:tt $new:expr) => { ... };
}
Expand description

Generate argument validator based on a list of types (used by [command!]).

This macro can be used to generate a closure that takes arguments as &[&str] and makes sure that the nubmer of arguments is correct and all can be parsed to appropriate types. This macro should generally not be used. Prefer to use [command!] which will use this macro appropriately.

Example usage:

let validator = validator!(i32, f32, String);
assert!(validator(&["10", "3.14", "hello"]).is_ok());

ยงNote

For string arguments use String instead of &str.