#version #comparison #semver #rust

compare_version

A Rust library for comparing semantic versioning strings and checking version compatibility

10 releases

new 0.2.8 Mar 11, 2025
0.2.7 Mar 2, 2025
0.2.6 Feb 9, 2025
0.2.5 Jan 20, 2025
0.1.1 Nov 1, 2024

#551 in Rust patterns

Download history 3/week @ 2024-11-18 123/week @ 2024-11-25 154/week @ 2024-12-02 46/week @ 2024-12-09 2/week @ 2025-01-06 127/week @ 2025-01-13 195/week @ 2025-01-20 103/week @ 2025-02-03 58/week @ 2025-02-10 8/week @ 2025-02-17 107/week @ 2025-02-24 53/week @ 2025-03-03

302 downloads per month

MIT license

15KB
216 lines

Compare version

Official Documentation

A Rust library for comparing semantic versioning strings and checking version compatibility.

Features

  • Version Comparison: Compare two semantic versioning strings to determine their order (greater, less, equal).
  • Version Range Matching: Check if a specific version matches a specified range using ^ and ~ notation.
  • Pre-release Support: Handle pre-release versions with proper comparison logic.
  • Error Handling: Comprehensive error types to handle version parsing and range issues gracefully.

Installation

To use this crate, you can run cmd:

cargo add compare_version

Examples

use compare_version::*;
let result = compare_versions("1.2.3", "1.2.4");
assert_eq!(result, Ok(VersionComparison::Less));
let matches = matches_version_range("1.2.3", "^1.2.0");
assert_eq!(matches, Ok(true));
let matches = matches_version_range("1.2.3", "~1.2.4");
assert_eq!(matches, Ok(false));

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Contact

For any inquiries, please reach out to the author at ltpp-universe root@ltpp.vip.

No runtime deps