pub trait AsPath {
// Required method
fn as_path(&self) -> &Path;
}Expand description
A trait for converting various types into a reference to a Path.
This trait is used to avoid redundant allocation of memory by providing a reference to a Path.
It is implemented only for types that can either be referenced or are references to Path itself.
Unlike TryIntoPath, it does not allocate memory on the heap. However, TryIntoPath is implemented for a wider range of types because it is not restricted from allocating memory.
Unlike AsRef< Path >, AsPath is implemented for a wider number of types, including those that are not directly convertible to a Path using AsRef.
This is because AsPath is designed to provide a more flexible interface for path-like types, accommodating various representations that can logically be treated as paths.