[−][src]Struct path_dsl::PathDSL
A PathBuf wrapper that has support for a Path DSL.
It is usable nearly identically to a PathBuf.
Supports Deref to
PathBuf to cover all edge cases.
Prefer using the path! macro.
See crate documentation for usage examples.
Methods
impl PathDSL[src]
pub fn new() -> Self[src]
Creates a new PathDSL with a new empty PathBuf inside
pub fn into_os_string(self) -> OsString[src]
Forwarder function for PathBuf::into_os_string
pub fn into_boxed_path(self) -> Box<Path>[src]
Forwarder function for PathBuf::into_boxed_path
pub fn into_pathbuf(self) -> PathBuf[src]
Converts this PathDSL into the underlying PathBuf
Methods from Deref<Target = PathBuf>
pub fn as_path(&self) -> &Path1.0.0[src]
Coerces to a Path slice.
Examples
use std::path::{Path, PathBuf}; let p = PathBuf::from("/test"); assert_eq!(Path::new("/test"), p.as_path());
pub fn push<P>(&mut self, path: P) where
P: AsRef<Path>, 1.0.0[src]
P: AsRef<Path>,
Extends self with path.
If path is absolute, it replaces the current path.
On Windows:
- if
pathhas a root but no prefix (e.g.,\windows), it replaces everything except for the prefix (if any) ofself. - if
pathhas a prefix but no root, it replacesself.
Examples
Pushing a relative path extends the existing path:
use std::path::PathBuf; let mut path = PathBuf::from("/tmp"); path.push("file.bk"); assert_eq!(path, PathBuf::from("/tmp/file.bk"));
Pushing an absolute path replaces the existing path:
use std::path::PathBuf; let mut path = PathBuf::from("/tmp"); path.push("/etc"); assert_eq!(path, PathBuf::from("/etc"));
pub fn pop(&mut self) -> bool1.0.0[src]
Truncates self to self.parent.
Returns false and does nothing if self.parent is None.
Otherwise, returns true.
Examples
use std::path::{Path, PathBuf}; let mut p = PathBuf::from("/test/test.rs"); p.pop(); assert_eq!(Path::new("/test"), p); p.pop(); assert_eq!(Path::new("/"), p);
pub fn set_file_name<S>(&mut self, file_name: S) where
S: AsRef<OsStr>, 1.0.0[src]
S: AsRef<OsStr>,
Updates self.file_name to file_name.
If self.file_name was None, this is equivalent to pushing
file_name.
Otherwise it is equivalent to calling pop and then pushing
file_name. The new path will be a sibling of the original path.
(That is, it will have the same parent.)
Examples
use std::path::PathBuf; let mut buf = PathBuf::from("/"); assert!(buf.file_name() == None); buf.set_file_name("bar"); assert!(buf == PathBuf::from("/bar")); assert!(buf.file_name().is_some()); buf.set_file_name("baz.txt"); assert!(buf == PathBuf::from("/baz.txt"));
pub fn set_extension<S>(&mut self, extension: S) -> bool where
S: AsRef<OsStr>, 1.0.0[src]
S: AsRef<OsStr>,
Updates self.extension to extension.
Returns false and does nothing if self.file_name is None,
returns true and updates the extension otherwise.
If self.extension is None, the extension is added; otherwise
it is replaced.
Examples
use std::path::{Path, PathBuf}; let mut p = PathBuf::from("/feel/the"); p.set_extension("force"); assert_eq!(Path::new("/feel/the.force"), p.as_path()); p.set_extension("dark_side"); assert_eq!(Path::new("/feel/the.dark_side"), p.as_path());
pub fn capacity(&self) -> usize[src]
path_buf_capacity)pub fn clear(&mut self)[src]
path_buf_capacity)pub fn reserve(&mut self, additional: usize)[src]
path_buf_capacity)pub fn reserve_exact(&mut self, additional: usize)[src]
path_buf_capacity)Invokes reserve_exact on the underlying instance of OsString.
pub fn shrink_to_fit(&mut self)[src]
path_buf_capacity)Invokes shrink_to_fit on the underlying instance of OsString.
pub fn shrink_to(&mut self, min_capacity: usize)[src]
path_buf_capacity)Trait Implementations
impl AsMut<PathBuf> for PathDSL[src]
impl Into<PathBuf> for PathDSL[src]
impl Into<OsString> for PathDSL[src]
impl Into<Box<Path>> for PathDSL[src]
impl<'a> Into<Cow<'a, Path>> for PathDSL[src]
impl<'a> Into<Cow<'a, Path>> for &'a PathDSL[src]
impl<'a> Into<Cow<'a, OsStr>> for &'a PathDSL[src]
impl<'a> Into<Arc<Path>> for PathDSL[src]
impl<'a> Into<Rc<Path>> for PathDSL[src]
impl Default for PathDSL[src]
impl Ord for PathDSL[src]
fn cmp(&self, other: &Self) -> Ordering[src]
fn max(self, other: Self) -> Self1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self[src]
clamp)Restrict a value to a certain interval. Read more
impl Clone for PathDSL[src]
fn clone(&self) -> PathDSL[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl PartialEq<PathDSL> for PathDSL[src]
fn eq(&self, other: &PathDSL) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl PartialEq<PathBuf> for PathDSL[src]
fn eq(&self, other: &PathBuf) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl PartialEq<Path> for PathDSL[src]
fn eq(&self, other: &Path) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl PartialEq<OsStr> for PathDSL[src]
fn eq(&self, other: &OsStr) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl PartialEq<OsString> for PathDSL[src]
fn eq(&self, other: &OsString) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl<'a> PartialEq<Cow<'a, Path>> for PathDSL[src]
fn eq(&self, other: &Cow<'a, Path>) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl<'a> PartialEq<Cow<'a, OsStr>> for PathDSL[src]
fn eq(&self, other: &Cow<'a, OsStr>) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl<P> Extend<P> for PathDSL where
P: AsRef<Path>, [src]
P: AsRef<Path>,
fn extend<I: IntoIterator<Item = P>>(&mut self, iter: I)[src]
impl AsRef<Path> for PathDSL[src]
impl AsRef<OsStr> for PathDSL[src]
impl<'_, T: ?Sized> From<&'_ T> for PathDSL where
T: AsRef<Path>, [src]
T: AsRef<Path>,
impl<'_, T: ?Sized> From<&'_ mut T> for PathDSL where
T: AsRef<Path>, [src]
T: AsRef<Path>,
impl From<PathBuf> for PathDSL[src]
impl From<OsString> for PathDSL[src]
impl From<String> for PathDSL[src]
impl From<Box<Path>> for PathDSL[src]
impl<'_> From<Cow<'_, Path>> for PathDSL[src]
impl<'_> From<Cow<'_, OsStr>> for PathDSL[src]
impl Eq for PathDSL[src]
impl<'a> IntoIterator for &'a PathDSL[src]
type Item = &'a OsStr
The type of the elements being iterated over.
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter[src]
impl PartialOrd<PathDSL> for PathDSL[src]
fn partial_cmp(&self, other: &PathDSL) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than (for self and other) and is used by the < operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl PartialOrd<PathBuf> for PathDSL[src]
fn partial_cmp(&self, other: &PathBuf) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than (for self and other) and is used by the < operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl PartialOrd<Path> for PathDSL[src]
fn partial_cmp(&self, other: &Path) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than (for self and other) and is used by the < operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl<'a> PartialOrd<Cow<'a, Path>> for PathDSL[src]
fn partial_cmp(&self, other: &Cow<'a, Path>) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than (for self and other) and is used by the < operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl<'a> PartialOrd<Cow<'a, OsStr>> for PathDSL[src]
fn partial_cmp(&self, other: &Cow<'a, OsStr>) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than (for self and other) and is used by the < operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl PartialOrd<OsStr> for PathDSL[src]
fn partial_cmp(&self, other: &OsStr) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than (for self and other) and is used by the < operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl PartialOrd<OsString> for PathDSL[src]
fn partial_cmp(&self, other: &OsString) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than (for self and other) and is used by the < operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl Deref for PathDSL[src]
impl DerefMut for PathDSL[src]
impl Debug for PathDSL[src]
impl Div<PathDSL> for PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: PathDSL) -> Self::Output[src]
impl<'_, T: ?Sized> Div<&'_ T> for PathDSL where
T: AsRef<Path>, [src]
T: AsRef<Path>,
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: &T) -> Self::Output[src]
impl<'_, T: ?Sized> Div<&'_ mut T> for PathDSL where
T: AsRef<Path>, [src]
T: AsRef<Path>,
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: &mut T) -> Self::Output[src]
impl Div<OsString> for PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: OsString) -> Self::Output[src]
impl Div<String> for PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: String) -> Self::Output[src]
impl Div<PathBuf> for PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: PathBuf) -> Self::Output[src]
impl Div<Box<Path>> for PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: Box<Path>) -> Self::Output[src]
impl<'_> Div<Cow<'_, Path>> for PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: Cow<Path>) -> Self::Output[src]
impl<'_> Div<Cow<'_, OsStr>> for PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: Cow<OsStr>) -> Self::Output[src]
impl<'_> Div<PathDSL> for &'_ PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: PathDSL) -> Self::Output[src]
impl<'_, '_, T: ?Sized> Div<&'_ T> for &'_ PathDSL where
T: AsRef<Path>, [src]
T: AsRef<Path>,
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: &T) -> Self::Output[src]
impl<'_, '_, T: ?Sized> Div<&'_ mut T> for &'_ PathDSL where
T: AsRef<Path>, [src]
T: AsRef<Path>,
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: &mut T) -> Self::Output[src]
impl<'_> Div<OsString> for &'_ PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: OsString) -> Self::Output[src]
impl<'_> Div<String> for &'_ PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: String) -> Self::Output[src]
impl<'_> Div<PathBuf> for &'_ PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: PathBuf) -> Self::Output[src]
impl<'_> Div<Box<Path>> for &'_ PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: Box<Path>) -> Self::Output[src]
impl<'_, '_> Div<Cow<'_, Path>> for &'_ PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: Cow<Path>) -> Self::Output[src]
impl<'_, '_> Div<Cow<'_, OsStr>> for &'_ PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: Cow<OsStr>) -> Self::Output[src]
impl<'_> Div<PathDSL> for &'_ mut PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: PathDSL) -> Self::Output[src]
impl<'_, '_, T: ?Sized> Div<&'_ T> for &'_ mut PathDSL where
T: AsRef<Path>, [src]
T: AsRef<Path>,
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: &T) -> Self::Output[src]
impl<'_, '_, T: ?Sized> Div<&'_ mut T> for &'_ mut PathDSL where
T: AsRef<Path>, [src]
T: AsRef<Path>,
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: &mut T) -> Self::Output[src]
impl<'_> Div<OsString> for &'_ mut PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: OsString) -> Self::Output[src]
impl<'_> Div<String> for &'_ mut PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: String) -> Self::Output[src]
impl<'_> Div<PathBuf> for &'_ mut PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: PathBuf) -> Self::Output[src]
impl<'_> Div<Box<Path>> for &'_ mut PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: Box<Path>) -> Self::Output[src]
impl<'_, '_> Div<Cow<'_, Path>> for &'_ mut PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: Cow<Path>) -> Self::Output[src]
impl<'_, '_> Div<Cow<'_, OsStr>> for &'_ mut PathDSL[src]
type Output = PathDSL
The resulting type after applying the / operator.
fn div(self, rhs: Cow<OsStr>) -> Self::Output[src]
impl Hash for PathDSL[src]
fn hash<H: Hasher>(&self, state: &mut H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher]. Read more
impl FromStr for PathDSL[src]
type Err = Infallible
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>[src]
impl Borrow<Path> for PathDSL[src]
Auto Trait Implementations
impl Sync for PathDSL
impl Unpin for PathDSL
impl Send for PathDSL
impl UnwindSafe for PathDSL
impl RefUnwindSafe for PathDSL
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T> From<T> for T[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,