Generates a `all()` function with all options for this enum
(name: &str, values: &[&'static str], fmt: &mut Formatter)
| 73 | |
| 74 | /// Generates a `all()` function with all options for this enum |
| 75 | fn gen_enum_all(name: &str, values: &[&'static str], fmt: &mut Formatter) { |
| 76 | fmtln!( |
| 77 | fmt, |
| 78 | "/// Returns a slice with all possible [{}] values.", |
| 79 | name |
| 80 | ); |
| 81 | fmt.add_block(&format!("pub fn all() -> &'static [{name}]"), |fmt| { |
| 82 | fmtln!(fmt, "&["); |
| 83 | fmt.indent(|fmt| { |
| 84 | for v in values.iter() { |
| 85 | fmtln!(fmt, "Self::{},", camel_case(v)); |
| 86 | } |
| 87 | }); |
| 88 | fmtln!(fmt, "]"); |
| 89 | }); |
| 90 | } |
| 91 | |
| 92 | /// Emit Display and FromStr implementations for enum settings. |
| 93 | fn gen_to_and_from_str(name: &str, values: &[&'static str], fmt: &mut Formatter) { |
no test coverage detected