This week I’ve published a Rust library for comparing, adding, and subtracting version-like inputs. Check the documentation for detailed getting started and usage instructions, the source code is available on GitHub. What follows is the TLDR for installation and usage…

Cargo.toml (snip)

[dependencies]
version_operators = "0.0.1"

src/main.rs (example)

use version_operators::Version;

fn main() {
    let version = Version::from_str("1.14.3");

    let expected = vec![1, 14, 3];

    assert_eq!(version.to_vector(), expected);
}

Application examples may be run by cloning the repository from GitHub

Clone

mkdir -vp ~/git/hub/rust-utilities

cd ~/git/hub/rust-utilities

git clone git@github.com:rust-utilities/version_operators.git

examples/version-compare.rs

cargo run --example version-compare '1.14.3' '-lt' '1.14.4'
#> true

cargo run --example version-compare '1.14.3' '==' '1.14.4'
#> false

examples/version-math.rs

cargo run --example version-math '1.14.4' '-add' '1.14.3'
#> [2, 28, 7]

cargo run --example version-math '1.14.4' '-sub' '1.14.3'
#> [0, 0, 1]

examples/version-increment.rs

cargo run --example version-increment '1.14.3' '1'
#> [1, 15, 3]