Crate relative_path [−] [src]
A platform-neutral relative path.
This provide types which are analogous to Path
, and PathBuf
found in stdlib, with the
following characteristics:
- The path separator is set to a fixed character (
/
), regardless of platform. - The parent of a logical single component (like
foo
,./foo
, andfoo/.
) isNone
instead ofSome("")
. - Relative paths cannot represent a path in the filesystem, without first specifying what they
are relative to through
to_path
.
When two relative paths are compared to each other, their exact component makeup is significant account:
use relative_path::RelativePath; assert!(RelativePath::new("foo/bar/../baz") != RelativePath::new("foo/baz"));
Two see if two logical paths are equivalent, use normalize
first:
use relative_path::RelativePath; assert_eq!( RelativePath::new("foo/bar/../baz").normalize(), RelativePath::new("foo/baz").normalize(), );
Serde Support
This library includes serde support that can be enabled with the serde
feature.
Structs
Components |
Iterator over all the components in a relative path. |
Display |
Helper struct for printing relative paths. |
Iter |
An iterator over the |
RelativePath |
A borrowed, immutable relative path. |
RelativePathBuf |
An owned, mutable relative path. |
StripPrefixError |
An error returned from |
Enums
Component |