fn normpath(path: &Path) -> io::Result<PathBuf> {
    let mut abspath = std::env::current_dir().unwrap();
    abspath.push(path);
    for ancestor in abspath.ancestors().skip(1) {
        if let Ok(canonical) = ancestor.canonicalize() {
            return Ok(canonical.join(abspath.strip_prefix(ancestor).unwrap()));
        }
    }
    Ok(abspath)
}
/// Best-effort canonicalization.
///
/// Canonicalizes the portions of the path that exist, ignores the rest.
/// Does not traverse terminal symlinks.
Best-effort canonicalization.
Canonicalizes the portions of the path that exist, ignores the rest.
Does not traverse terminal symlinks.
Best - effort canonicalization . Canonicalizes the portions of the path that exist ignores the rest . Does not traverse terminal symlinks .
fn normpath(path: &Path) -> io::Result<PathBuf> {
    let mut abspath = std::env::current_dir().unwrap();
    abspath.push(path);
    for ancestor in abspath.ancestors().skip(1) {
        if let Ok(canonical) = ancestor.canonicalize() {
            return Ok(canonical.join(abspath.strip_prefix(ancestor).unwrap()));
        }
    }
    Ok(abspath)
}
fn normpath ( path : & Path ) -> io :: Result < PathBuf > { let mut abspath = std :: env :: current_dir ( ) . unwrap ( ) ; abspath . push ( path ) ; for ancestor in abspath . ancestors ( ) . skip ( 1 ) { if let Ok ( canonical ) = ancestor . canonicalize ( ) { return Ok ( canonical . join ( abspath . strip_prefix ( ancestor ) . unwrap ( ) ) ) ; } } Ok ( abspath ) }
Best-effort canonicalization.
Best - effort canonicalization .
path
&Path
path
&Path