Struct Path

Source
pub struct Path<'a, 'b> { /* private fields */ }
Expand description

A Path can be used to represent a path.

A path is a sequence of parts that are joined together by a joiner. The joiner is a string that is used to split the path into parts and into a PathBuf.

§Example

use postcard_bindgen_core::path::Path;

let path = Path::new("foo/bar/baz", "/");

assert_eq!(path.parts().collect::<Vec<&str>>(), vec!["foo", "bar", "baz"]);

Implementations§

Source§

impl<'a, 'b> Path<'a, 'b>

Source

pub fn new( path: impl Into<FullPath<'a>>, joiner: impl Into<Cow<'b, str>>, ) -> Self

Create a new path from something which can be converted into a FullPath and a joiner which is either str or String.

Source

pub fn parts(&self) -> impl Iterator<Item = &str>

Gives an iterator over the parts of the path.

Source

pub fn flatten(&mut self)

Flatten the path to the root by simply removing all parts.

Source

pub fn into_buf(self) -> PathBuf<'a>

Convert the path into a PathBuf by consuming the path and splitting it into parts.

Source

pub fn is_empty(&self) -> bool

Check if the path is empty.

Source

pub fn into_owned(self) -> Path<'static, 'static>

Convert the path into an owned path by consuming the path.

Trait Implementations§

Source§

impl<'a, 'b> Clone for Path<'a, 'b>

Source§

fn clone(&self) -> Path<'a, 'b>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, 'b> Debug for Path<'a, 'b>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Path<'_, '_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<L: Lang> FormatInto<L> for Path<'_, '_>

Source§

fn format_into(self, t: &mut Tokens<L>)

Convert the type into tokens in-place. Read more
Source§

impl<'a, 'b> From<Path<'a, 'b>> for String

Source§

fn from(value: Path<'a, 'b>) -> Self

Converts to this type from the input type.
Source§

impl<'a, 'b> PartialEq for Path<'a, 'b>

Source§

fn eq(&self, other: &Path<'a, 'b>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> Eq for Path<'a, 'b>

Source§

impl<'a, 'b> StructuralPartialEq for Path<'a, 'b>

Auto Trait Implementations§

§

impl<'a, 'b> Freeze for Path<'a, 'b>

§

impl<'a, 'b> RefUnwindSafe for Path<'a, 'b>

§

impl<'a, 'b> Send for Path<'a, 'b>

§

impl<'a, 'b> Sync for Path<'a, 'b>

§

impl<'a, 'b> Unpin for Path<'a, 'b>

§

impl<'a, 'b> UnwindSafe for Path<'a, 'b>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.