Crates.io | semver_sort |
lib.rs | semver_sort |
version | 1.0.0 |
source | src |
created_at | 2023-05-28 03:34:13.631499 |
updated_at | 2023-05-28 06:46:33.770017 |
description | Sorts semver strings or numbers |
homepage | |
repository | https://github.com/ragingwind/rust-semver-sort |
max_upload_size | |
id | 876243 |
size | 15,429 |
Sorts semver strings or numbers. and more util functions
Add the following to your Cargo.toml:
[dependencies]
semver_sort = "1"
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 }
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
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"]