talira

semver (Rust)

Parser and evaluator for Cargo's flavor of Semantic Versioning

open sourceMIT OR Apache-2.0free

semver is David Tolnay's Rust crate for parsing and comparing version numbers the way Cargo does. It parses versions with pre-release and build metadata, parses requirements such as >=1.2.3, <1.8.0, and checks whether a version matches a requirement. Where tools differ in how they read the Semantic Versioning spec, it follows Cargo's choices, so it's meant for Cargo and crates.io versions rather than npm's or RubyGems'. Not the same as the npm package semver.

Problems it solves

  • parse and compare semantic version numbers in Rust
  • check whether a crate version satisfies a Cargo version requirement
  • sort release versions with pre-release tags in Rust

Features

  • parse versions with pre-release and build metadata
  • parse version requirements like >=1.2.3, <1.8.0
  • check whether a version matches a requirement
  • follows Cargo's interpretation of SemVer

Limitations

  • Follows Cargo's interpretation of SemVer; for versions from other ecosystems (npm, RubyGems, Composer) its README recommends a library made for that ecosystem.1