Skip to main content

NormalizePath

Trait NormalizePath 

Source
pub trait NormalizePath {
    // Required methods
    fn normalize(&self) -> PathBuf;
    fn try_normalize(&self) -> Option<PathBuf>;
    fn is_normalized(&self) -> bool;
}
Expand description

Extension trait to add normalize_path to std’s Path.

Required Methods§

Source

fn normalize(&self) -> PathBuf

Normalize a path without performing I/O.

All redundant separator and up-level references are collapsed.

However, this does not resolve links.

Source

fn try_normalize(&self) -> Option<PathBuf>

Same as NormalizePath::normalize except that if Component::Prefix/Component::RootDir is encountered, or if the path points outside of current dir, returns None.

Source

fn is_normalized(&self) -> bool

Return true if the path is normalized.

§Quirk

If the path does not start with ./ but contains ./ in the middle, then this function might returns true.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl NormalizePath for Path

Implementors§