pub struct VersionRequirement {
pub comparison: VersionComparison,
pub version: Version,
}
Expand description
A version requirement, e.g. for a dependency package.
It consists of a target version and a comparison function. A version requirement of >=1.5
has
a target version of 1.5
and a comparison function of VersionComparison::GreaterOrEqual
.
§Examples
use std::str::FromStr;
use alpm_types::{Version, VersionComparison, VersionRequirement};
let requirement = VersionRequirement::from_str(">=1.5").unwrap();
assert_eq!(requirement.comparison, VersionComparison::GreaterOrEqual);
assert_eq!(requirement.version, Version::from_str("1.5").unwrap());
Fields§
§comparison: VersionComparison
§version: Version
Implementations§
source§impl VersionRequirement
impl VersionRequirement
sourcepub fn new(comparison: VersionComparison, version: Version) -> Self
pub fn new(comparison: VersionComparison, version: Version) -> Self
Create a new VersionRequirement
sourcepub fn is_satisfied_by(&self, ver: &Version) -> bool
pub fn is_satisfied_by(&self, ver: &Version) -> bool
Returns true
if the requirement is satisfied by the given package version.
§Examples
use std::str::FromStr;
use alpm_types::{Version, VersionRequirement};
let requirement = VersionRequirement::from_str(">=1.5-3").unwrap();
assert!(!requirement.is_satisfied_by(&Version::from_str("1.5").unwrap()));
assert!(requirement.is_satisfied_by(&Version::from_str("1.5-3").unwrap()));
assert!(requirement.is_satisfied_by(&Version::from_str("1.6").unwrap()));
assert!(requirement.is_satisfied_by(&Version::from_str("2:1.0").unwrap()));
assert!(!requirement.is_satisfied_by(&Version::from_str("1.0").unwrap()));
Trait Implementations§
source§impl Clone for VersionRequirement
impl Clone for VersionRequirement
source§fn clone(&self) -> VersionRequirement
fn clone(&self) -> VersionRequirement
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 VersionRequirement
impl Debug for VersionRequirement
source§impl Display for VersionRequirement
impl Display for VersionRequirement
source§impl FromStr for VersionRequirement
impl FromStr for VersionRequirement
source§impl PartialEq for VersionRequirement
impl PartialEq for VersionRequirement
impl Eq for VersionRequirement
impl StructuralPartialEq for VersionRequirement
Auto Trait Implementations§
impl Freeze for VersionRequirement
impl RefUnwindSafe for VersionRequirement
impl Send for VersionRequirement
impl Sync for VersionRequirement
impl Unpin for VersionRequirement
impl UnwindSafe for VersionRequirement
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
)