3 releases (1 stable)

1.0.0 May 28, 2023
0.2.0 May 28, 2023
0.1.0 May 28, 2023

#2987 in Parser implementations

23 downloads per month

MIT license

6KB
93 lines

semver_sort

Sorts semver strings or numbers. and more util functions

Usage

Add the following to your Cargo.toml:

[dependencies]
semver_sort = "1"

API

semver_regex

Parse semver string to Semver type

use semver_sort::{
  semver::semver_regex
};

print!("{:?}", semver_regex("1.2.3-alpha.10.beta"));
// Semver { major: "1", minor: "2", patch: "3", prerelease: Some("alpha.10.beta"), buildmetadata: None }

semver_compare

Compare returns Ordering

use semver_sort::{
    semver::semver_compare,
    semver::Semver,
};

semver_compare("0.0.0-abc", "0.0.0-abc", true);
// Ordering::Equal

semver_compare("0.0.0-bcd", "0.0.0-abc", true);
// Ordering::Great

semver_compare("0.0.0-abc", "0.0.0-bcd", true); 
// Ordering::Less

semver_sort

Returns sorted semver

semver_sort(["0.0.4-abc", "0.0.3-abc", "0.0.1-abc", "0.0.2-abc", "0.0.0-abc"]);
// ["0.0.0-abc", "0.0.1-abc", "0.0.2-abc", "0.0.3-abc", "0.0.4-abc"]

License

Dependencies

~2.2–3MB
~55K SLoC