29 lines
761 B
Rust
29 lines
761 B
Rust
|
pub fn _search_subfolders(path: &Path) -> Vec<String> {
|
||
|
let dirs = std::fs::read_dir(path).unwrap();
|
||
|
let mut folders: Vec<String> = vec![];
|
||
|
for dir in dirs {
|
||
|
let dirpath = dir.unwrap().path();
|
||
|
let path = Path::new(dirpath.as_path());
|
||
|
if path.is_dir() {
|
||
|
folders.push(dirpath.to_str().unwrap().to_string());
|
||
|
for f in _search_subfolders(path) {
|
||
|
folders.push(f);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
folders
|
||
|
}
|
||
|
|
||
|
pub fn _dedup<T: Ord + PartialOrd>(list: &mut Vec<T>) -> usize {
|
||
|
// Begin with sorting entries
|
||
|
list.sort();
|
||
|
// Then deduplicate
|
||
|
list.dedup();
|
||
|
// Return the length
|
||
|
list.len()
|
||
|
}
|
||
|
|
||
|
pub async fn _sleep_ms(ms: u64) {
|
||
|
sleep(Duration::from_millis(ms)).await;
|
||
|
}
|