MCPcopy Create free account
hub / github.com/Wulf/create-rust-app / file_path_to_vec_string

Function file_path_to_vec_string

crates/qsync/src/utils.rs:5–15  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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)
5pub 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]
18fn test_file_path_to_vec_string() {

Callers 2

generate_hook_nameFunction · 0.85

Calls 1

to_stringMethod · 0.80

Tested by 1