use version_compare::{Cmp, Version};
fn main() {
let a = "1.2";
let b = "1.5.1";
assert_eq!(version_compare::compare(a, b).unwrap(), Cmp::Lt);
assert_eq!(version_compare::compare_to(a, b, Cmp::Le).unwrap(), true);
assert_eq!(version_compare::compare_to(a, b, Cmp::Gt).unwrap(), false);
let a = Version::from(a).unwrap();
let b = Version::from(b).unwrap();
assert_eq!(a < b, true);
assert_eq!(a <= b, true);
assert_eq!(a > b, false);
assert_eq!(a != b, true);
assert_eq!(a.compare(&b), Cmp::Lt);
assert_eq!(b.compare(&a), Cmp::Gt);
assert_eq!(a.compare_to(&b, Cmp::Lt), true);
match a.compare(b) {
Cmp::Lt => println!("Version a is less than b"),
Cmp::Eq => println!("Version a is equal to b"),
Cmp::Gt => println!("Version a is greater than b"),
_ => unreachable!(),
}
}