pub struct RelativePath(PathBuf);
Expand description
A representation of a relative file path
RelativePath
wraps a PathBuf
that is guaranteed to represent a
relative file path (i.e. it does not end with a /
).
§Examples
use std::path::PathBuf;
use std::str::FromStr;
use alpm_types::{Error, RelativePath};
// Create RelativePath from &str
assert_eq!(
RelativePath::from_str("etc/test.conf"),
RelativePath::new(PathBuf::from("etc/test.conf"))
);
assert_eq!(
RelativePath::from_str("/etc/test.conf"),
Err(Error::PathNotRelative(PathBuf::from("/etc/test.conf")))
);
// Format as String
assert_eq!(
"test/test.txt",
RelativePath::from_str("test/test.txt")?.to_string()
);
Tuple Fields§
§0: PathBuf
Implementations§
Trait Implementations§
source§impl Clone for RelativePath
impl Clone for RelativePath
source§fn clone(&self) -> RelativePath
fn clone(&self) -> RelativePath
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RelativePath
impl Debug for RelativePath
source§impl Display for RelativePath
impl Display for RelativePath
source§impl FromStr for RelativePath
impl FromStr for RelativePath
source§impl PartialEq for RelativePath
impl PartialEq for RelativePath
impl Eq for RelativePath
impl StructuralPartialEq for RelativePath
Auto Trait Implementations§
impl Freeze for RelativePath
impl RefUnwindSafe for RelativePath
impl Send for RelativePath
impl Sync for RelativePath
impl Unpin for RelativePath
impl UnwindSafe for RelativePath
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)