Skip to main content

PathExt

Trait PathExt 

Source
pub trait PathExt {
    // Required method
    fn clean(&self) -> PathBuf;
}
Expand description

Extension methods for Path.

Required Methods§

Source

fn clean(&self) -> PathBuf

Normalizes a path using purely lexical analysis.

The following normalization rules are applied iteratively:

  • Multiple contiguous path separators are replaced with a single MAIN_SEPARATOR.
  • Current directory components (.) are removed.
  • Parent directory components (..) that do not occur at the beginning of the path are removed along with the preceding component.
  • Parent directory components at the start of a rooted path (e.g., /..) are removed.
  • Empty paths are replaced with “.”.

The returned path ends in a separator only if it represents the root directory.

This method is a port of Go’s path.Clean function.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl PathExt for Path

Source§

fn clean(&self) -> PathBuf

Implementors§