Function compare_to

Source
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.

If either version number string is invalid an error is returned.

§Examples

use version_compare::{Cmp, compare_to};

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());