pub struct OptDepend {
name: Name,
description: Option<String>,
}
Expand description
An optional dependency for a package.
This type is used for representing dependencies that are not essential for base functionality of a package, but may be necessary to make use of certain features of a package.
An OptDepend
consists of a name and an optional description separated by a colon (:
).
- The name component must be a valid
Name
. - If a description is provided it must be at least one character long.
§Note
It’s currently not possible to specify a version in an optional dependency due to the limitations of the current file format.
§Examples
use std::str::FromStr;
use alpm_types::{Name, OptDepend};
// Create OptDepend from &str
let opt_depend = OptDepend::from_str("example: this is an example dependency")?;
// Get the name
assert_eq!("example", opt_depend.name().as_ref());
// Get the description
assert_eq!(
Some("this is an example dependency"),
opt_depend.description().as_deref()
);
// Format as String
assert_eq!(
"example: this is an example dependency",
format!("{opt_depend}")
);
Fields§
§name: Name
§description: Option<String>
Implementations§
Trait Implementations§
source§impl Ord for OptDepend
impl Ord for OptDepend
source§impl PartialOrd for OptDepend
impl PartialOrd for OptDepend
impl Eq for OptDepend
impl StructuralPartialEq for OptDepend
Auto Trait Implementations§
impl Freeze for OptDepend
impl RefUnwindSafe for OptDepend
impl Send for OptDepend
impl Sync for OptDepend
impl Unpin for OptDepend
impl UnwindSafe for OptDepend
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
)