Skip to main content

spell

Function spell 

Source
pub fn spell(root: Option<&Path>, path: &Path) -> String
Expand description

How a path is spelled against root.

One function for both sides of the wire. A helper writes its anchors with it and a reader looks them up with it, so the two spellings agree because they are the same rule rather than because they were written to match.

A path made relative has its components separated by / whatever the platform separates them with. Where a file sits inside the project is a value on the wire, in the audit database and in every exported report, so it has to read as one name rather than one per operating system — and Windows opens a path spelled that way as readily as its own.

A path outside root keeps its own name, exactly as it stands: made relative it would climb out of the project with .., which says less than the path it started as, and respelled it would stop being what the filesystem answered — a Windows path reached past the ordinary rules is spelled one way only.