MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / gen_enum_all

Function gen_enum_all

cranelift/codegen/meta/src/gen_settings.rs:75–90  ·  view source on GitHub ↗

Generates a `all()` function with all options for this enum

(name: &str, values: &[&'static str], fmt: &mut Formatter)

Source from the content-addressed store, hash-verified

73
74/// Generates a `all()` function with all options for this enum
75fn 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.
93fn gen_to_and_from_str(name: &str, values: &[&'static str], fmt: &mut Formatter) {

Callers 1

gen_enum_typesFunction · 0.85

Calls 3

add_blockMethod · 0.45
indentMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected