mavlink_bindgen/
util.rs

1use std::path::PathBuf;
2
3pub fn to_module_name<P: Into<PathBuf>>(file_name: P) -> String {
4    file_name
5        .into()
6        .file_stem() // remove extension
7        .unwrap()
8        .to_string_lossy() // convert to string
9        .to_lowercase() // all lowercase
10        .replace(|c: char| !c.is_alphanumeric(), "_") // remove non alphanum
11}
12
13pub fn to_dialect_name<P: Into<PathBuf>>(file_name: P) -> String {
14    file_name
15        .into()
16        .file_stem() // remove extension
17        .unwrap()
18        .to_string_lossy()
19        .to_string()
20}