#version #matching #semver #compile-time #look #full #requirenments

no-std fast-version

Fast version requirenments and matching

3 unstable releases

0.2.1 May 1, 2022
0.1.1 Apr 29, 2022
0.1.0 Apr 29, 2022

#22 in #look

MIT license

23KB
369 lines

fast-version

license shield crates.io shield

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)

Example

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

Dependencies

~0.5–1MB
~23K SLoC