pub struct OwnedPath { /* private fields */ }Expand description
OwnedPath is the equivalent of PathBuf in the normal std library.
It is a path whose inner representation is a String.
The path can be modified by adding other paths using the OwnedPath::push method.
Implementations§
Source§impl OwnedPath
impl OwnedPath
pub fn as_path(&self) -> &Path
Sourcepub fn push<P: AsRef<Path>>(&mut self, segment: P)
pub fn push<P: AsRef<Path>>(&mut self, segment: P)
Appends another path to the end of this path. If the other path is absolute, but this path is not empty, then the path will be appended as a relative path.
use kstd::path::owned::OwnedPath;
let mut path = OwnedPath::from("foo");
path.push("/bar");
assert_eq!(path.to_string(), "foo/bar");Pushing a parent directory will not remove the last component of the path:
use kstd::path::owned::OwnedPath;
let mut path = OwnedPath::from("foo/bar");
path.push("..");
assert_eq!(path.to_string(), "foo/bar/..");Pushing a root dir is a no-op if the path is not empty, otherwise it will make this path absolute.
use kstd::path::owned::OwnedPath;
let mut path = OwnedPath::new();
path.push("/");
path.push("foo");
assert_eq!(path.to_string(), "/foo");Pushing a current dir is always a no-op and will not modify the path in any way.
Sourcepub fn into_components(self) -> Vec<OwnedPath>
pub fn into_components(self) -> Vec<OwnedPath>
Converts the path into its components.
use kstd::path::owned::OwnedPath;
let mut my_root = OwnedPath::from("/my/path");
assert_eq!(vec![OwnedPath::from("my"), OwnedPath::from("path")], my_root.into_components());pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn components(&self) -> Components<'_> ⓘ
Trait Implementations§
impl Eq for OwnedPath
Source§impl Ord for OwnedPath
impl Ord for OwnedPath
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for OwnedPath
impl PartialOrd for OwnedPath
impl StructuralPartialEq for OwnedPath
Auto Trait Implementations§
impl Freeze for OwnedPath
impl RefUnwindSafe for OwnedPath
impl Send for OwnedPath
impl Sync for OwnedPath
impl Unpin for OwnedPath
impl UnsafeUnpin for OwnedPath
impl UnwindSafe for OwnedPath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more