I was pointed to this crate from the comments on a Reddit post I made, and thought I'd take notes about things that confused me while reading the documentation.
Errors always include filenames? That's awesome!
In the list of types introduced in this crate, PathArc
is first and therefore presumably most important, but it's not actually used anywhere in the examples? So maybe it's just an implementation detail I should ignore?
In the crate-level docs, PathAbs
says "An absolute (not necessarily canonicalized) path that may or may not exist" but the documentation for PathAbs::new()
says "The path must exist or io::Error will be returned."? Must the path exist, or not?
I'm interested in working with paths that may or may not exist, but the example at the top of the file only creates these structs with ::create()
, creating them on disk at the same time, so it doesn't particularly help me.
I see PathArc
has an absolute()
method, which does the broken thing of resolving /../
segments semantically, which means it's almost never safe to use. It's a shame; the other parts of its functionality are pretty useful, and there's other useful cleanups it could perform (like removing empty //
path segments, and normalizing delimiters to /
or \
depending on platform), but while there's a chance that it will corrupt a path I'd rather not use it.
The specific functionality I was looking for in my Reddit post, and which I can't seem to find in your crate, was partial canonicalization. Instead of Rust's canonicalize
which requires the the entire path exist, a method that requires all-but-the-last-segment exists, or even a method that silently switches from real canonicalization to semantic canonicalization at the first segment that does not exist.