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. - Relative paths cannot represent an absolute path in the filesystem, without first specifying
what they are relative to through
to_path
.
Absolute Paths
Relative paths can be absolute. This does not have the same meaning as with Path
, instead it
only affects how relative paths are adjoined.
Joining one absolute path, with another effectively replaces it:
use relative_path::RelativePath; let path = RelativePath::new("foo/bar").join("/baz"); assert_eq!("/baz", path)
Using an absolute [RelativePath
] won't affect how it's converted into a Path
.
use relative_path::RelativePath; use std::path::Path; let path = RelativePath::new("/baz").to_path(Path::new(".")); assert_eq!(Path::new("./baz"), path)
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. |
RelativePath |
A borrowed, immutable relative path. |
RelativePathBuf |
An owned, mutable relative path. |