Skip to main content

canonicalize

Function canonicalize 

Source
pub fn canonicalize(path: impl AsRef<Path>) -> Result<PathBuf>
Expand description

Canonicalize a filesystem path without the Windows \\?\ verbatim prefix.

std::fs::canonicalize returns verbatim (\\?\) paths on Windows, which break path comparisons, round-tripping through user config, and some APIs that reject verbatim paths. dunce::canonicalize strips the prefix when it is safe to do so and is a perfect drop-in on non-Windows platforms.

This is the single canonical entry point for path canonicalization in the workspace. All call sites should use this (or canonicalize_workspace) rather than std::fs::canonicalize / Path::canonicalize, which are banned by clippy.toml’s disallowed-methods.