Skip to main content

Join

Trait Join 

Source
pub trait Join<T: ?Sized>: Joinable {
    // Required method
    fn join(&self, other: &T) -> PathBuf;
}
Expand description

This trait is used to implement joining of a path or path component to a Path or PathBuf.

This is required as the semantics of joining a path to a path, versus joining a string to a path are not the same, but they are consistent for specific pairs of types.

This trait is public in order to use it as a constraint for Path::join, but it is sealed to only allow it to be implemented on Path and PathBuf.

Required Methods§

Source

fn join(&self, other: &T) -> PathBuf

Joins other to self, producing a new PathBuf containing the joined path.

Implementations must choose one of two strategies for joining, depending on what T represents:

  1. If T is a type that can represent a multi-component path, then you should prefer to construct a Path or PathBuf from T, and delegate to <Path as Join<Path>>::join. This approach is akin to converting self to a PathBuf, and calling PathBuf::push on it.
  2. If T is a type that represents a symbol or single-component path, then you should prefer to convert the T to a &str/String/Ident and delegate to the corresponding implementation of Join for Path. This approach is akin to converting self to a PathBuf and calliing PathBuf::push_component on it.

Implementors§