pub struct RelativeFilePath(/* private fields */);Expand description
A representation of a relative file path
RelativeFilePath 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, RelativeFilePath};
// Create RelativeFilePath from &str
assert_eq!(
RelativeFilePath::from_str("etc/test.conf"),
RelativeFilePath::new(PathBuf::from("etc/test.conf"))
);
assert_eq!(
RelativeFilePath::from_str("/etc/test.conf"),
Err(Error::PathNotRelative(PathBuf::from("/etc/test.conf")))
);
// Format as String
assert_eq!(
"test/test.txt",
RelativeFilePath::from_str("test/test.txt")?.to_string()
);Implementations§
Trait Implementations§
Source§impl Clone for RelativeFilePath
impl Clone for RelativeFilePath
Source§fn clone(&self) -> RelativeFilePath
fn clone(&self) -> RelativeFilePath
Returns a duplicate 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 RelativeFilePath
impl Debug for RelativeFilePath
Source§impl<'de> Deserialize<'de> for RelativeFilePath
impl<'de> Deserialize<'de> for RelativeFilePath
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 RelativeFilePath
impl Display for RelativeFilePath
Source§impl FromStr for RelativeFilePath
impl FromStr for RelativeFilePath
Source§impl PartialEq for RelativeFilePath
impl PartialEq for RelativeFilePath
Source§impl Serialize for RelativeFilePath
impl Serialize for RelativeFilePath
impl Eq for RelativeFilePath
impl StructuralPartialEq for RelativeFilePath
Auto Trait Implementations§
impl Freeze for RelativeFilePath
impl RefUnwindSafe for RelativeFilePath
impl Send for RelativeFilePath
impl Sync for RelativeFilePath
impl Unpin for RelativeFilePath
impl UnwindSafe for RelativeFilePath
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