pub trait PathMod {
// Required methods
fn is_dot(&self) -> bool;
fn last_component(&self) -> Option<PathBuf>;
fn first_component(&self) -> Option<PathBuf>;
fn as_str(&self) -> &str;
fn as_string(&self) -> String;
}Expand description
Adds some useful functions for manipulating and retrieving information from paths
Required Methods§
Sourcefn is_dot(&self) -> bool
fn is_dot(&self) -> bool
Returns true if the path’s file name starts with a “.”
§Example
use rpf::PathMod;
use std::path::Path;
let path = Path::new("/test/dot/.dotfile");
assert_eq!(path.is_dot(), true);Sourcefn last_component(&self) -> Option<PathBuf>
fn last_component(&self) -> Option<PathBuf>
Returns a PathBuf of &self’s last component
§Example
use rpf::PathMod;
use std::path::PathBuf;
let path = PathBuf::from("/tmp/test/mod");
let last = path.last_component().unwrap();
assert_eq!(last, PathBuf::from("mod"));Sourcefn first_component(&self) -> Option<PathBuf>
fn first_component(&self) -> Option<PathBuf>
Returns a PathBuf of &self’s first component
§Example
use rpf::PathMod;
use std::path::PathBuf;
let path = PathBuf::from("/tmp/test/mod");
let first = path.first_component().unwrap();
assert_eq!(first, PathBuf::from("/"));