pub struct OptionalDependency {
package_relation: PackageRelation,
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 OptionalDependency
consists of a package relation and an optional description separated
by a colon (:
).
- The package relation component must be a valid
PackageRelation
. - If a description is provided it must be at least one character long.
§Examples
use std::str::FromStr;
use alpm_types::{Name, OptionalDependency};
// Create OptionalDependency from &str
let opt_depend = OptionalDependency::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§
§package_relation: PackageRelation
§description: Option<String>
Implementations§
Source§impl OptionalDependency
impl OptionalDependency
Sourcepub fn new(
package_relation: PackageRelation,
description: Option<String>,
) -> OptionalDependency
pub fn new( package_relation: PackageRelation, description: Option<String>, ) -> OptionalDependency
Create a new OptionalDependency in a Result
Sourcepub fn version_requirement(&self) -> &Option<VersionRequirement>
pub fn version_requirement(&self) -> &Option<VersionRequirement>
Return the version requirement of the optional dependency
Sourcepub fn description(&self) -> &Option<String>
pub fn description(&self) -> &Option<String>
Return the description for the optional dependency, if it exists
Trait Implementations§
Source§impl Clone for OptionalDependency
impl Clone for OptionalDependency
Source§fn clone(&self) -> OptionalDependency
fn clone(&self) -> OptionalDependency
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 OptionalDependency
impl Debug for OptionalDependency
Source§impl Display for OptionalDependency
impl Display for OptionalDependency
Source§impl FromStr for OptionalDependency
impl FromStr for OptionalDependency
Source§impl PartialEq for OptionalDependency
impl PartialEq for OptionalDependency
Source§impl Serialize for OptionalDependency
impl Serialize for OptionalDependency
impl Eq for OptionalDependency
impl StructuralPartialEq for OptionalDependency
Auto Trait Implementations§
impl Freeze for OptionalDependency
impl RefUnwindSafe for OptionalDependency
impl Send for OptionalDependency
impl Sync for OptionalDependency
impl Unpin for OptionalDependency
impl UnwindSafe for OptionalDependency
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