Converts a `/home/user/path/to/file.rs` to `["home", "user", "path", "to", "file"]` Note: this trims the `.rs` extension from the filename (the last element in the vec)
(input_path: &std::path::Path)
| 3 | /// Converts a `/home/user/path/to/file.rs` to `["home", "user", "path", "to", "file"]` |
| 4 | /// Note: this trims the `.rs` extension from the filename (the last element in the vec) |
| 5 | pub fn file_path_to_vec_string(input_path: &std::path::Path) -> Vec<String> { |
| 6 | let mut s: Vec<String> = vec![]; |
| 7 | |
| 8 | for path in input_path.components() { |
| 9 | let path_as_string = path.as_os_str().to_str().unwrap_or_default().to_string(); |
| 10 | let path_as_string = path_as_string.trim_end_matches(".rs").to_string(); |
| 11 | s.push(path_as_string.clone()); |
| 12 | } |
| 13 | |
| 14 | s.iter().map(Inflector::to_pascal_case).collect() |
| 15 | } |
| 16 | |
| 17 | #[test] |
| 18 | fn test_file_path_to_vec_string() { |