pub trait PathExt {
// Required methods
fn normalize(&self) -> PathBuf;
fn canonicalize_or_self(&self) -> PathBuf;
fn file_name_str(&self) -> String;
}Expand description
Extension trait that adds path normalization and safety methods to Path.
Delegates to the existing free functions in this module, providing a more ergonomic call-site syntax:
use vtcode_commons::paths::PathExt;
use std::path::Path;
let normalized = Path::new("/tmp/project/src/../src/lib.rs").normalize();Required Methods§
Sourcefn canonicalize_or_self(&self) -> PathBuf
fn canonicalize_or_self(&self) -> PathBuf
Canonicalize with fallback to the original path if canonicalization fails.
Sourcefn file_name_str(&self) -> String
fn file_name_str(&self) -> String
Extract the filename from a path as a String, with fallback to the
full path when no filename component exists.
Unlike Path::file_name which returns Option<&OsStr>, this method
always returns a String and falls back gracefully.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".