mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-04-20 03:03:25 -04:00
21 lines
697 B
Rust
21 lines
697 B
Rust
/// Create a clap parser for an enum which implements `strum::{EnumString, EnumVariantNames}`
|
|
#[macro_export]
|
|
macro_rules! clap_enum_variants {
|
|
($e: ty) => {{
|
|
use clap::builder::TypedValueParser;
|
|
use strum::VariantNames;
|
|
clap::builder::PossibleValuesParser::new(<$e>::VARIANTS).map(|s| s.parse::<$e>().unwrap())
|
|
}};
|
|
}
|
|
|
|
/// Call a function using a given field generic
|
|
#[macro_export]
|
|
macro_rules! call_with_field {
|
|
($function:ident::<$field:ident>($($args:expr),*) ) => {
|
|
match $field {
|
|
FieldArgument::Gl => $function::<GoldilocksField>($($args),*),
|
|
FieldArgument::Bn254 => $function::<Bn254Field>($($args),*),
|
|
}
|
|
};
|
|
}
|