[][src]Struct smart_path::SmartPathBuf

pub struct SmartPathBuf { /* fields omitted */ }

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]

fn range(&self, range: RangeFull) -> Self[src]

Returns a new SmartPath from the range provided

impl PathRange<RangeTo<usize>> for SmartPathBuf[src]

fn range(&self, range: RangeTo<usize>) -> Self[src]

Returns a new SmartPath from the range provided

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]

fn range(&self, range: Range<usize>) -> Self[src]

Returns a new SmartPath from the range provided

impl<'_, T: ?Sized> From<&'_ T> for SmartPathBuf where
    T: AsRef<OsStr>, 
[src]

impl From<OsString> for SmartPathBuf[src]

impl From<String> for SmartPathBuf[src]

impl From<PathBuf> for SmartPathBuf[src]

impl<P: AsRef<Path>> Extend<P> for SmartPathBuf[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?

impl Clone for SmartPathBuf[src]

impl Default for SmartPathBuf[src]

fn default() -> Self[src]

Constructs an empty SmartPathBuf.

impl Eq for SmartPathBuf[src]

impl Ord for SmartPathBuf[src]

impl PartialEq<SmartPathBuf> for SmartPathBuf[src]

impl<'a, 'b> PartialEq<PathBuf> for SmartPathBuf[src]

impl<'a, 'b> PartialEq<SmartPathBuf> for PathBuf[src]

impl<'a, 'b> PartialEq<Path> for SmartPathBuf[src]

impl<'a, 'b> PartialEq<SmartPathBuf> for Path[src]

impl<'a, 'b> PartialEq<&'a Path> for SmartPathBuf[src]

impl<'a, 'b> PartialEq<SmartPathBuf> for &'a Path[src]

impl<'a, 'b> PartialEq<OsStr> for SmartPathBuf[src]

impl<'a, 'b> PartialEq<SmartPathBuf> for OsStr[src]

impl<'a, 'b> PartialEq<&'a OsStr> for SmartPathBuf[src]

impl<'a, 'b> PartialEq<SmartPathBuf> for &'a OsStr[src]

impl<'a, 'b> PartialEq<Cow<'a, OsStr>> for SmartPathBuf[src]

impl<'a, 'b> PartialEq<SmartPathBuf> for Cow<'a, OsStr>[src]

impl<'a, 'b> PartialEq<OsString> for SmartPathBuf[src]

impl<'a, 'b> PartialEq<SmartPathBuf> for OsString[src]

impl PartialOrd<SmartPathBuf> for SmartPathBuf[src]

impl<'a, 'b> PartialOrd<PathBuf> for SmartPathBuf[src]

impl<'a, 'b> PartialOrd<SmartPathBuf> for PathBuf[src]

impl<'a, 'b> PartialOrd<Path> for SmartPathBuf[src]

impl<'a, 'b> PartialOrd<SmartPathBuf> for Path[src]

impl<'a, 'b> PartialOrd<&'a Path> for SmartPathBuf[src]

impl<'a, 'b> PartialOrd<SmartPathBuf> for &'a Path[src]

impl<'a, 'b> PartialOrd<OsStr> for SmartPathBuf[src]

impl<'a, 'b> PartialOrd<SmartPathBuf> for OsStr[src]

impl<'a, 'b> PartialOrd<&'a OsStr> for SmartPathBuf[src]

impl<'a, 'b> PartialOrd<SmartPathBuf> for &'a OsStr[src]

impl<'a, 'b> PartialOrd<Cow<'a, OsStr>> for SmartPathBuf[src]

impl<'a, 'b> PartialOrd<SmartPathBuf> for Cow<'a, OsStr>[src]

impl<'a, 'b> PartialOrd<OsString> for SmartPathBuf[src]

impl<'a, 'b> PartialOrd<SmartPathBuf> for OsString[src]

impl Debug for SmartPathBuf[src]

impl FromStr for SmartPathBuf[src]

type Err = Infallible

The associated error which can be returned from parsing.

impl Deref for SmartPathBuf[src]

type Target = Path

The resulting type after dereferencing.

impl Index<usize> for SmartPathBuf[src]

type Output = OsString

The returned type after indexing.

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.

impl<P: AsRef<Path>> FromIterator<P> for SmartPathBuf[src]

impl Borrow<Path> for SmartPathBuf[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]