Here is the implementation that I see in my version of Rust:
#[stable(feature = "rust1", since = "1.0.0")]
impl AsRef<Path> for PathBuf {
#[inline]
fn as_ref(&self) -> &Path {
self
}
}
It says that the implementation for converting a &PathBuf to a &Path is simply to return self, which implies that &PathBuf is &Path (or that the compiler itself knows that they can be converted automatically)?
These are 2 different structs right? How does the compiler know that this is okay?