pub trait PathExt {
    fn clean(&self) -> PathBuf;
Expand description

Extension methods for Path.

Required Methods

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.

Implementations on Foreign Types