A Rust library to easily compare version numbers in any format, and test them against various comparison operators.
Comparing version numbers is hard. Especially when version numbers get really complex, or when their formatting differs.
This library helps you to easily compare any kind of version number with minimal code. Two version numbers can be compared to each other, to get a relevant comparison operator (<, ==, >), or version numbers can be tested against any given comparison operator.
Along with version comparison, the library also features other useful tools. For example: version numbers can be parsed to inspect a version number by it’s bare numeric or text based parts.
Inspired by PHPs version_compare().
A list of version number examples that are parsed successfully:
. -32 . 1(undefined formats)
MyApp 3.2.0 / build 0932(complex formats, not fully functional yet)
- Many more and support for custom formats to come…
Version number formats like semver try to make version numbers consistent and manageable, there are too many projects however that don’t follow such format.
Version-compare makes working with them easy and supports semver formats out of the box with zero configuration.
- Compare two version numbers, get:
- Compare two version numbers against any comparison operator, get
- Parse complex version numbers.
- Static, single-statement methods available.
The following features will be added in a later version:
- Support for text parts in version strings.
- Version manifest, to specify detailed version number constraints.
- Version ranges, and tests against them.
- Support for operators in version strings, npm-style, and tests against them.
- Batch comparisons.
Check out the examples directory for all available examples.
pub use crate::comp_op::CompOp;
pub use crate::version::Version;
pub use crate::version_compare::VersionCompare;
pub use crate::version_manifest::VersionManifest;
pub use crate::version_part::VersionPart;
Module with all supported comparison operators.
Version module, which provides the
Version struct as parsed version representation.
Version compare module, with useful static comparison methods.
Module for the version manifest.
Version part module.