Commit ca425943e7
Unsigned
Layout: unified · split
src/config.rs +4 −10
| @@ -107,22 +107,16 @@ macro_rules! bool_create { | |||
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | macro_rules! integer_create { | 109 | macro_rules! integer_create { |
| 110 | ($option_name:ident, $description:literal, $default:literal, $min:literal, $max:literal, [$($string_value:literal), *]) => { | 110 | ($option_name:ident, $description:literal, $default:literal, $min:literal, $max:literal) => { |
| 111 | paste::item! { | 111 | paste::item! { |
| 112 | fn [<create_option_ $option_name>](section: &mut SectionHandleMut) { | 112 | fn [<create_option_ $option_name>](section: &mut SectionHandleMut) { |
| 113 | let mut string_values: Vec<String> = Vec::new(); | ||
| 114 | |||
| 115 | $( | ||
| 116 | string_values.push($string_value.into()); | ||
| 117 | )* | ||
| 118 | |||
| 119 | let option_name = stringify!($option_name); | 113 | let option_name = stringify!($option_name); |
| 114 | |||
| 120 | let option_settings = IntegerOptionSettings::new(option_name) | 115 | let option_settings = IntegerOptionSettings::new(option_name) |
| 121 | .description($description) | 116 | .description($description) |
| 122 | .default_value($default) | 117 | .default_value($default) |
| 123 | .min($min) | 118 | .min($min) |
| 124 | .max($max) | 119 | .max($max); |
| 125 | .string_values(string_values); | ||
| 126 | 120 | ||
| 127 | section.new_integer_option(option_settings) | 121 | section.new_integer_option(option_settings) |
| 128 | .expect(&format!("Can't create option {}", option_name)); | 122 | .expect(&format!("Can't create option {}", option_name)); |
| @@ -193,7 +187,7 @@ macro_rules! option { | |||
| 193 | }; | 187 | }; |
| 194 | 188 | ||
| 195 | (Integer, $option_name:ident, $description:literal, $default:literal, $min:literal..$max:literal $(,)?) => { | 189 | (Integer, $option_name:ident, $description:literal, $default:literal, $min:literal..$max:literal $(,)?) => { |
| 196 | integer_create!($option_name, $description, $default, $min, $max, []); | 190 | integer_create!($option_name, $description, $default, $min, $max); |
| 197 | option_getter!(Integer, $option_name, i64); | 191 | option_getter!(Integer, $option_name, i64); |
| 198 | }; | 192 | }; |
| 199 | 193 | ||