Hi I have a source structure like
src/main.rs
src/elements/element1.rs
src/elements/element2.rs
src/elements/element3.rs
…
I want to create a macro that reads src/elements dir and calls a function in each file.
What I have so far is something like
macro_rules! read_elements {
() => {
let paths = fs::read_dir("src/elements").unwrap();
let names =
paths.filter_map(|entry| {
entry.ok().and_then(|e|
e.path().file_stem()
.and_then(|n| n.to_str().map(|s| String::from(s)))
)
}).collect::<Vec<String>>();
// for n in &names {
// elements::n::get_type_information();
// }
};
}
The problem occurs in the commented area above where I have to call a function in each file.
Does anyone know if I can get the macro to call a function in a module given the module name ?
Thanks