Function edres::codegen::define_enum_from_filenames
source · [−]pub fn define_enum_from_filenames(
root: &Path,
enum_name: &str,
options: &Options
) -> Result<TokenStream, Error>
Expand description
Define Rust enum based on the file names within the given directory.
Examples
let tokens = codegen::define_enum_from_filenames(
"./my_dir".as_ref(),
"FileEnum",
&Options::minimal(),
).unwrap();
assert_eq!(tokens.to_string(), quote!(
pub enum FileEnum {
// From ./my_dir/file_a.toml
FileA,
// From ./my_dir/file_b.toml
FileB,
}
).to_string());