Crates.io | fast-version |
lib.rs | fast-version |
version | 0.2.1 |
source | src |
created_at | 2022-04-29 17:32:05.271886 |
updated_at | 2022-05-01 09:42:38.451268 |
description | Fast version requirenments and matching |
homepage | |
repository | |
max_upload_size | |
id | 577446 |
size | 5,900 |
Utility crate for fast SemVer like Versions and Version Requirenments. If you look for full SemVer experience and/or easy usage, please consider the excellent semver crate.
This implementation however doesn't require allocations, thus can be used in compile time evaluation. (support for embedded will follow)
use fast_version::{Version, VersionReq, VersionReqVariant, const_version};
const VERSION: Version = const_version!("1.2.3");
assert_eq!(VERSION.major, 1);
assert_eq!(VERSION.minor, 2);
assert_eq!(VERSION.patch, 3);
const VERSION_REQ_MATCH: VersionReq = {
let version_req_variant = VersionReqVariant::Strict(VERSION);
VersionReq::new(&version_req_variant)
};
assert!(VERSION_REQ_MATCH.matches(&VERSION));
const VERSION_REQ_UNMATCH: VersionReq = {
let version_req_variant = VersionReqVariant::MajorLessEqual { major: 0 };
VersionReq::new(&version_req_variant)
};
assert!(!VERSION_REQ_UNMATCH.matches(&VERSION));
License: MIT