[][src]Trait mmrbi::PathExt

pub trait PathExt {
    fn cleanup(&self) -> PathBuf;
}

Utility methods for std::path::Path[Buf]

Required methods

fn cleanup(&self) -> PathBuf

Cleanup/simplify path as much as possible

Examples

use mmrbi::PathExt;
 
assert_eq!(Path::new("a/b").cleanup(),                      Path::new("a/b"));
assert_eq!(Path::new("a/b/..").cleanup(),                   Path::new("a"));
assert_eq!(Path::new("a/b/../..").cleanup(),                Path::new("."));
assert_eq!(Path::new("a/b/../../..").cleanup(),             Path::new(".."));
assert_eq!(Path::new("a/b/../../../..").cleanup(),          Path::new("../.."));
 
assert_eq!(Path::new("../../a/b").cleanup(),                Path::new("../../a/b"));
assert_eq!(Path::new("../../a/b/..").cleanup(),             Path::new("../../a"));
assert_eq!(Path::new("../../a/b/../..").cleanup(),          Path::new("../.."));
assert_eq!(Path::new("../../a/b/../../..").cleanup(),       Path::new("../../.."));
assert_eq!(Path::new("../../a/b/../../../..").cleanup(),    Path::new("../../../.."));

if cfg!(windows) {
    assert_eq!(Path::new(r"C:\foo\bar").cleanup(),          Path::new(r"C:\foo\bar"));
    assert_eq!(Path::new(r"\\?\C:\foo\bar").cleanup(),      Path::new(r"C:\foo\bar"));
}
Loading content...

Implementations on Foreign Types

impl<'_> PathExt for &'_ Path[src]

impl PathExt for PathBuf[src]

Loading content...

Implementors

Loading content...