semver_sort

Crates.iosemver_sort
lib.rssemver_sort
version1.0.0
sourcesrc
created_at2023-05-28 03:34:13.631499
updated_at2023-05-28 06:46:33.770017
descriptionSorts semver strings or numbers
homepage
repositoryhttps://github.com/ragingwind/rust-semver-sort
max_upload_size
id876243
size15,429
Jimmy Moon (ragingwind)

documentation

README

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

Commit count: 9

cargo fmt