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, 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<'de> Deserialize<'de> for RelativePath
impl<'de> Deserialize<'de> for RelativePath
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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
Source§impl Serialize for RelativePath
impl Serialize 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