macro_rules! options {
( $( $opt_name:ident : $opt_value:expr ),* ) => { ... };
}
Expand description
options!
is a declarative macro that facilitates the creation of an Options
instance.
§Usage
This macro can be used to construct an instance of Options
using a more readable and
ergonomic syntax. The syntax of the macro is:
options!{
OptionName1: value1,
OptionName2: value2,
...
}
Here, OptionNameN
is the identifier of the option you want to set, and valueN
is the value
you want to assign to that option.
§Example
let options = options!{
FooBar: "lol",
SomeReadyMadeOption: "another_value"
};
In this example, an instance of Options
is being created with two options: FooBar
and
SomeReadyMadeOption
, which are set to "lol"
and "another_value"
, respectively.
§Notes
-
The option identifier (
OptionNameN
) must match an enum variant inOpt
. If the identifier does not match any of theOpt
variants, a compilation error will occur. -
The value (
valueN
) should be of a type that is acceptable for the corresponding option. If the value type does not match the expected type for the option, a compilation error will occur.