Crates.io | flexver-rs |
lib.rs | flexver-rs |
version | 0.1.2 |
source | src |
created_at | 2022-11-06 21:39:38.680735 |
updated_at | 2022-12-21 02:21:53.533436 |
description | Comparer for FlexVer-spec versions |
homepage | |
repository | https://github.com/unascribed/FlexVer |
max_upload_size | |
id | 706759 |
size | 9,045 |
A Rust implementation of FlexVer.
You can either copy (and rename) lib.rs wholesale into your project, or retrieve it from crates.io like so in Cargo.toml
:
[dependencies]
flexver-rs = "0.1.2"
The crate provides both a compare
function and the FlexVer
struct. The FlexVer
struct implements Ord
, and thus supports all of the comparison operations.
fn compare(left: &str, right: &str) -> std::cmp::Ordering; // Type signature
assert_eq!(compare("1.0.0", "1.1.0"), Ordering::Less);
struct FlexVer(&str); // Type signature
assert!(FlexVer("1.0.0") < FlexVer("1.1.0"));
You can find additional examples in the tests section at the bottom of lib.rs.