Function version_compare::compare_to[][src]

pub fn compare_to<A, B>(a: A, b: B, operator: Cmp) -> Result<bool, ()> where
    A: AsRef<str>,
    B: AsRef<str>, 
Expand description

Compare two version number strings to each other and test against the given comparison operator.

The two given version numbers must be valid, or an error will be returned.

Examples

use version_compare::{Cmp, compare_to};

// Compare version numbers
assert!(compare_to("1.2.3", "1.2.3", Cmp::Eq).unwrap());
assert!(compare_to("1.2.3", "1.2.3", Cmp::Le).unwrap());
assert!(compare_to("1.2.3", "1.2.4", Cmp::Lt).unwrap());
assert!(compare_to("1", "0.1", Cmp::Gt).unwrap());
assert!(compare_to("1", "0.1", Cmp::Ge).unwrap());