Skip to main content

resolve_under

Function resolve_under 

Source
pub fn resolve_under(base: &Path, path: &Path) -> PathBuf
Expand description

Resolve a possibly-relative path against base, returning a lexically normalized PathBuf.

Behavior:

  • Absolute path passes through unchanged (only normalized).
  • Relative path is joined onto base.
  • . and .. components are collapsed lexically — purely by string manipulation, without touching the filesystem and without requiring the path (or its parents) to exist.

Lexical (rather than std::fs::canonicalize) resolution is the deliberate choice for tool path handling: write/patch tools must resolve targets that do not yet exist on disk, and canonicalization both fails for missing paths and silently rewrites symlinks. Tools that genuinely need symlink-real-path resolution for an existence/scope check should use canonicalize_under instead and accept that it requires the path to exist.