Skip to content

version

Semantic Versioning 2.0.0: parsing, precedence, bumps and Cargo-style requirements.

Version is a strict semver version (with a lenient parser for v1.2), VersionReq a requirement such as ^1.2 or >=1.0, <2.0 using Cargo’s rules, and compare / satisfies are the one-line versions for strings. Bad input is a typed error, never a guess.

Cargo feature version (enabled by default). To compile only this module:

cargo add helpers4 --no-default-features --features version

or in Cargo.toml:

[dependencies]
helpers4 = { version = "0.0.6", default-features = false, features = ["version"] }

Import path: helpers4::version.

ItemWhat it does
compareCompares two version strings by semver precedence.
satisfiesWhether the version version satisfies the requirement requirement, both given as text.
VersionA Semantic Versioning 2.0.0 version: MAJOR.MINOR.PATCH, optionally with a pre-release (-alpha.1) and build metadata (+sha.5114f85).
VersionReqA version requirement such as ^1.2, >=1.0, <2.0 or 1.*: which versions are acceptable.

Documented on the page of the helper that returns them.

TypeReturned by
ParseVersionErrorcompare, satisfies, Version, VersionReq