[−][src]Struct version_compare::version_compare::VersionCompare
The main library structure, which provides various static methods for easy version comparison.
This structure uses static methods only, and doesn't need to be constructed.
Methods
impl VersionCompare
[src]
pub fn compare(a: &str, b: &str) -> Result<CompOp, ()>
[src]
Compare two version number strings to each other.
This compares version a
to version b
, and returns whether version a
is greater, less
or equal to version b
.
The two given version numbers must be valid, or an error will be returned.
One of the following ok results may be returned:
CompOp::Eq
CompOp::Lt
CompOp::Gt
Examples
use version_compare::{CompOp, VersionCompare}; // Compare version numbers assert_eq!(VersionCompare::compare("1.2.3", "1.2.3"), Ok(CompOp::Eq)); assert_eq!(VersionCompare::compare("1.2.3", "1.2.4"), Ok(CompOp::Lt)); assert_eq!(VersionCompare::compare("1", "0.1"), Ok(CompOp::Gt));
pub fn compare_to(a: &str, b: &str, operator: &CompOp) -> Result<bool, ()>
[src]
Compare two version number strings to each other and check whether the given comparison
operator
is valid.
The two given version numbers must be valid, or an error will be returned.
Examples
use version_compare::{CompOp, VersionCompare}; // Compare version numbers assert!(VersionCompare::compare_to("1.2.3", "1.2.3", &CompOp::Eq).unwrap()); assert!(VersionCompare::compare_to("1.2.3", "1.2.3", &CompOp::Le).unwrap()); assert!(VersionCompare::compare_to("1.2.3", "1.2.4", &CompOp::Lt).unwrap()); assert!(VersionCompare::compare_to("1", "0.1", &CompOp::Gt).unwrap()); assert!(VersionCompare::compare_to("1", "0.1", &CompOp::Ge).unwrap());
Auto Trait Implementations
impl Send for VersionCompare
impl Unpin for VersionCompare
impl Sync for VersionCompare
impl UnwindSafe for VersionCompare
impl RefUnwindSafe for VersionCompare
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,