Download statistics Crate version Documentation Build status on GitLab CI License

Rust library to easily compare version numbers with no specific format, and test against various comparison operators.

Comparing version numbers is hard, especially with weird version number formats.

This library helps you to easily compare any kind of version number with no specific format using a best-effort approach. Two version numbers can be compared to each other to get a comparison operator (<, ==, >), or test them against a comparison operator.

Along with version comparison, the library provides various other tools for working with version numbers.

use version_compare::{compare, Cmp};

fn main() {
    let a = "1.3";
    let b = "1.2.4";

    match compare(a, b) {
        Ok(Cmp::Lt) => println!("Version a is less than b"),
        Ok(Cmp::Eq) => println!("Version a is equal to b"),
        Ok(Cmp::Gt) => println!("Version a is greater than b"),
        _ => panic!("Invalid version number"),

View more on the project pages over at: