pub struct PathBuf<'a> { /* private fields */ }Expand description
A path buffer that can be used to build paths.
The difference between a PathBuf and a Path is that a PathBuf is mutable and can be
modified, while a Path is immutable and is joined into one but knows how to split it into
parts.
§Example
use postcard_bindgen_core::path::PathBuf;
let mut path = PathBuf::new();
assert!(path.is_empty());
path.push("foo");
path.push("bar");
path.push("baz");
assert!(!path.is_empty());
assert_eq!(path.parts().map(|p| p.as_ref()).collect::<Vec<&str>>(), vec!["foo", "bar", "baz"]);Implementations§
Source§impl<'a> PathBuf<'a>
impl<'a> PathBuf<'a>
Sourcepub fn join(self, joiner: impl Into<Part<'a>>) -> Self
pub fn join(self, joiner: impl Into<Part<'a>>) -> Self
Join a part into the path buffer by consuming the PathBuf.
This allows to chain calls to join parts into the path buffer.
§Example
use postcard_bindgen_core::path::PathBuf;
let path = PathBuf::new().join("foo").join("bar").join("baz");
assert_eq!(path.parts().map(|p| p.as_ref()).collect::<Vec<&str>>(), vec!["foo", "bar", "baz"]);Sourcepub fn push_front(&mut self, part: impl Into<Part<'a>>)
pub fn push_front(&mut self, part: impl Into<Part<'a>>)
Push a part to the front of the path buffer.
Sourcepub fn parts(&self) -> impl Iterator<Item = &Part<'a>>
pub fn parts(&self) -> impl Iterator<Item = &Part<'a>>
Gives an iterator over the parts of the path buffer.
Sourcepub fn into_path<'b>(self, joiner: impl Into<Part<'b>>) -> Path<'a, 'b>
pub fn into_path<'b>(self, joiner: impl Into<Part<'b>>) -> Path<'a, 'b>
Convert the path buffer into a Path by consuming the path buffer.
Sourcepub fn into_owned(self) -> PathBuf<'static>
pub fn into_owned(self) -> PathBuf<'static>
Convert the path buffer into an owned path buffer by consuming the path buffer.
Trait Implementations§
Source§impl<'a> Ord for PathBuf<'a>
impl<'a> Ord for PathBuf<'a>
1.21.0 · 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<'a> PartialOrd for PathBuf<'a>
impl<'a> PartialOrd for PathBuf<'a>
impl<'a> Eq for PathBuf<'a>
impl<'a> StructuralPartialEq for PathBuf<'a>
Auto Trait Implementations§
impl<'a> Freeze for PathBuf<'a>
impl<'a> RefUnwindSafe for PathBuf<'a>
impl<'a> Send for PathBuf<'a>
impl<'a> Sync for PathBuf<'a>
impl<'a> Unpin for PathBuf<'a>
impl<'a> UnwindSafe for PathBuf<'a>
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