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§
Sourcefn join(&self, other: &T) -> PathBuf
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:
- If
Tis a type that can represent a multi-component path, then you should prefer to construct a Path or PathBuf fromT, and delegate to<Path as Join<Path>>::join. This approach is akin to convertingselfto a PathBuf, and callingPathBuf::pushon it. - If
Tis a type that represents a symbol or single-component path, then you should prefer to convert theTto a&str/String/Identand delegate to the corresponding implementation ofJoinfor Path. This approach is akin to convertingselfto a PathBuf and calliingPathBuf::push_componenton it.