1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use convert_case::{Case, Casing};

/// Util function that convert a rust module path to the ClassPath used in Fitnesse.
pub fn from_rust_module_path_to_class_path(rust_module_path: &str) -> String {
    join(
        rust_module_path
            .split("::")
            .map(|s| s.to_case(Case::Pascal)),
        ".",
    )
}

fn join<T: AsRef<str>>(iterator: impl Iterator<Item = T>, separator: &str) -> String {
    let mut result = String::new();
    let mut first = true;
    for part in iterator {
        if !first {
            result += separator;
        }
        result += part.as_ref();
        first = false
    }
    result
}