[−][src]Struct smart_path::SmartPathBuf
Methods
impl SmartPathBuf[src]
pub fn new() -> SmartPathBuf[src]
Constructs a new SmartPathBuf.
Examples
use smart_path::SmartPathBuf; let mut smart_path = SmartPathBuf::new();
pub fn as_path(&self) -> &Path[src]
Returns a Path same as as_ref but more explicit.
pub fn len(&self) -> usize[src]
len is the number of segments, on "*nix" systems
if absolute this includes "/".
pub fn is_empty(&self) -> bool[src]
If there are no segments in this path returns true.
pub fn push<P: AsRef<Path>>(&mut self, path: P)[src]
When pushing segments to a new SmartPathBuf first push sets the initial size,
using one of the from methods also sets initial size.
Examples
use std::path::PathBuf; use smart_path::SmartPathBuf; let mut path = SmartPathBuf::new(); path.push("hello/world/bye"); // or let mut path = SmartPathBuf::from("hello/world/bye"); path.push("more/stuff"); path.initial(); assert_eq!(path.as_path(), PathBuf::from("hello/world/bye").as_path());
pub fn pop(&mut self) -> bool[src]
Remove segment from end of path.
pub fn pop_last(&mut self)[src]
Remove the last added segment(s) from end of path.
Examples
use std::path::PathBuf; use smart_path::SmartPathBuf; let mut path = SmartPathBuf::new(); path.push("hello/world/bye"); path.push("more/stuff"); path.pop_last(); assert_eq!(path.as_path(), PathBuf::from("hello/world/bye").as_path());
pub fn initial(&mut self)[src]
Resets SmartPathBuf to the initial path.
Examples
use std::path::PathBuf; use smart_path::SmartPathBuf; let mut path = SmartPathBuf::new(); path.push("hello/world/bye"); path.push("more/stuff"); path.push("even/more"); path.initial(); assert_eq!(path.as_path(), PathBuf::from("hello/world/bye").as_path());
pub fn set_file_name<S: AsRef<OsStr>>(&mut self, file_name: S)[src]
Updates file_name to the given file name.
If file_name was None, this is equivalent to pushing
another segment that is a file name.
Otherwise it is equivalent to calling pop and then pushing
a file name.
Examples
use smart_path::SmartPathBuf; let mut buf = SmartPathBuf::from("/"); assert!(buf.file_name() == None); buf.set_file_name("bar"); assert!(buf == SmartPathBuf::from("/bar")); assert!(buf.file_name().is_some()); buf.set_file_name("baz.txt"); assert!(buf == SmartPathBuf::from("/baz.txt"));
pub fn set_extension<S: AsRef<OsStr>>(&mut self, extension: S) -> bool[src]
Updates extension to the given extension.
Returns false and does nothing if file_name is None,
returns true and updates the extension otherwise.
Examples
use std::path::Path; use smart_path::SmartPathBuf; let mut p = SmartPathBuf::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 into_boxed_path(self) -> Box<Path>[src]
Boxes a Path up for you.
pub fn into_os_string(self) -> OsString[src]
Returns a new OsString.
Trait Implementations
impl PathRange<RangeFull> for SmartPathBuf[src]
impl PathRange<RangeTo<usize>> for SmartPathBuf[src]
impl PathRange<RangeFrom<usize>> for SmartPathBuf[src]
fn range(&self, range: RangeFrom<usize>) -> Self[src]
Returns a new SmartPath from the range provided
impl PathRange<Range<usize>> for SmartPathBuf[src]
impl<'_, T: ?Sized> From<&'_ T> for SmartPathBuf where
T: AsRef<OsStr>, [src]
T: AsRef<OsStr>,
fn from(s: &T) -> SmartPathBuf[src]
impl From<OsString> for SmartPathBuf[src]
fn from(s: OsString) -> SmartPathBuf[src]
impl From<String> for SmartPathBuf[src]
fn from(s: String) -> SmartPathBuf[src]
impl From<PathBuf> for SmartPathBuf[src]
fn from(s: PathBuf) -> SmartPathBuf[src]
impl<P: AsRef<Path>> Extend<P> for SmartPathBuf[src]
fn extend<I: IntoIterator<Item = P>>(&mut self, iter: I)[src]
impl<'a> IntoIterator for &'a SmartPathBuf[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) -> Iter<'a>[src]
impl Clone for SmartPathBuf[src]
fn clone(&self) -> SmartPathBuf[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Default for SmartPathBuf[src]
impl Eq for SmartPathBuf[src]
impl Ord for SmartPathBuf[src]
fn cmp(&self, other: &Self) -> Ordering[src]
fn max(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> Self1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self[src]
impl PartialEq<SmartPathBuf> for SmartPathBuf[src]
impl<'a, 'b> PartialEq<PathBuf> for SmartPathBuf[src]
impl<'a, 'b> PartialEq<SmartPathBuf> for PathBuf[src]
fn eq(&self, other: &SmartPathBuf) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialEq<Path> for SmartPathBuf[src]
impl<'a, 'b> PartialEq<SmartPathBuf> for Path[src]
fn eq(&self, other: &SmartPathBuf) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialEq<&'a Path> for SmartPathBuf[src]
impl<'a, 'b> PartialEq<SmartPathBuf> for &'a Path[src]
fn eq(&self, other: &SmartPathBuf) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialEq<OsStr> for SmartPathBuf[src]
impl<'a, 'b> PartialEq<SmartPathBuf> for OsStr[src]
fn eq(&self, other: &SmartPathBuf) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialEq<&'a OsStr> for SmartPathBuf[src]
impl<'a, 'b> PartialEq<SmartPathBuf> for &'a OsStr[src]
fn eq(&self, other: &SmartPathBuf) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialEq<Cow<'a, OsStr>> for SmartPathBuf[src]
fn eq(&self, other: &Cow<'a, OsStr>) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialEq<SmartPathBuf> for Cow<'a, OsStr>[src]
fn eq(&self, other: &SmartPathBuf) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialEq<OsString> for SmartPathBuf[src]
impl<'a, 'b> PartialEq<SmartPathBuf> for OsString[src]
fn eq(&self, other: &SmartPathBuf) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialOrd<SmartPathBuf> for SmartPathBuf[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialOrd<PathBuf> for SmartPathBuf[src]
fn partial_cmp(&self, other: &PathBuf) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialOrd<SmartPathBuf> for PathBuf[src]
fn partial_cmp(&self, other: &SmartPathBuf) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialOrd<Path> for SmartPathBuf[src]
fn partial_cmp(&self, other: &Path) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialOrd<SmartPathBuf> for Path[src]
fn partial_cmp(&self, other: &SmartPathBuf) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialOrd<&'a Path> for SmartPathBuf[src]
fn partial_cmp(&self, other: &&'a Path) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialOrd<SmartPathBuf> for &'a Path[src]
fn partial_cmp(&self, other: &SmartPathBuf) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialOrd<OsStr> for SmartPathBuf[src]
fn partial_cmp(&self, other: &OsStr) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialOrd<SmartPathBuf> for OsStr[src]
fn partial_cmp(&self, other: &SmartPathBuf) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialOrd<&'a OsStr> for SmartPathBuf[src]
fn partial_cmp(&self, other: &&'a OsStr) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialOrd<SmartPathBuf> for &'a OsStr[src]
fn partial_cmp(&self, other: &SmartPathBuf) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialOrd<Cow<'a, OsStr>> for SmartPathBuf[src]
fn partial_cmp(&self, other: &Cow<'a, OsStr>) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialOrd<SmartPathBuf> for Cow<'a, OsStr>[src]
fn partial_cmp(&self, other: &SmartPathBuf) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialOrd<OsString> for SmartPathBuf[src]
fn partial_cmp(&self, other: &OsString) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'a, 'b> PartialOrd<SmartPathBuf> for OsString[src]
fn partial_cmp(&self, other: &SmartPathBuf) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl Debug for SmartPathBuf[src]
impl FromStr for SmartPathBuf[src]
type Err = Infallible
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>[src]
impl Deref for SmartPathBuf[src]
impl Index<usize> for SmartPathBuf[src]
type Output = OsString
The returned type after indexing.
fn index(&self, idx: usize) -> &Self::Output[src]
impl Index<Range<usize>> for SmartPathBuf[src]
type Output = [OsString]
The returned type after indexing.
fn index(&self, rng: Range<usize>) -> &Self::Output[src]
On unix the / is always the first element in a Path
impl Index<RangeFull> for SmartPathBuf[src]
type Output = [OsString]
The returned type after indexing.
fn index(&self, rng: RangeFull) -> &Self::Output[src]
On unix the / is always the first element in a Path
impl Index<RangeFrom<usize>> for SmartPathBuf[src]
type Output = [OsString]
The returned type after indexing.
fn index(&self, rng: RangeFrom<usize>) -> &Self::Output[src]
On unix the / is always the first element in a Path
impl Index<RangeTo<usize>> for SmartPathBuf[src]
type Output = [OsString]
The returned type after indexing.
fn index(&self, rng: RangeTo<usize>) -> &Self::Output[src]
On unix the / is always the first element in a Path
impl IndexMut<usize> for SmartPathBuf[src]
impl IndexMut<Range<usize>> for SmartPathBuf[src]
fn index_mut(&mut self, rng: Range<usize>) -> &mut Self::Output[src]
On unix the / is always the first element in a Path
impl IndexMut<RangeFull> for SmartPathBuf[src]
fn index_mut(&mut self, rng: RangeFull) -> &mut Self::Output[src]
On unix the / is always the first element in a Path
impl IndexMut<RangeFrom<usize>> for SmartPathBuf[src]
fn index_mut(&mut self, rng: RangeFrom<usize>) -> &mut Self::Output[src]
On unix the / is always the first element in a Path
impl IndexMut<RangeTo<usize>> for SmartPathBuf[src]
fn index_mut(&mut self, rng: RangeTo<usize>) -> &mut Self::Output[src]
On unix the / is always the first element in a Path
impl Hash for SmartPathBuf[src]
fn hash<H: Hasher>(&self, h: &mut H)[src]
Hashes the inner Path value not SmartPathBuf.
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<P: AsRef<Path>> FromIterator<P> for SmartPathBuf[src]
fn from_iter<I: IntoIterator<Item = P>>(iter: I) -> SmartPathBuf[src]
impl Borrow<Path> for SmartPathBuf[src]
Auto Trait Implementations
impl Send for SmartPathBuf
impl Sync for SmartPathBuf
impl Unpin for SmartPathBuf
impl UnwindSafe for SmartPathBuf
impl RefUnwindSafe for SmartPathBuf
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> From<T> for T[src]
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, 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,