Skip to main content

path_key

Function path_key 

Source
pub fn path_key(path: &Path) -> PathBuf
Expand description

The key that every spelling of one path shares, as far as text can say.

Path::components is what does the work: it drops a trailing separator and the . inside a path, so /usr/include/ and /usr/include are one directory, and ./dir/x.h and dir/x.h are one file. .. is left alone, since a component above a symlink does not go where reading the path suggests.

This is text, not identity. Two names for one file through a symlink or a hard link are two keys here, where a compiler that asked the file system would get one answer. Asking would mean a stat per include on a path where the whole point is not to open the file at all.