cyberex 0.3.48

Utilities Library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pub fn path_to_string<P>(p: P) -> String
where
    P: AsRef<std::path::Path>,
{
    p.as_ref().display().to_string()
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_path_to_string() {
        use std::path::{Path, PathBuf};
        assert_eq!(path_to_string("/hello/world"), "/hello/world");
        assert_eq!(path_to_string(Path::new("/hello/world")), "/hello/world");
        assert_eq!(path_to_string(PathBuf::from("/hello/world")), "/hello/world");
    }
}