semver
Rust parser and evaluator for Cargo's flavor of Semantic Versioning
Repository Health
Technical Analysis
The semver crate is the reference Rust implementation for parsing and evaluating Semantic Versioning strings and version requirements, matching Cargo’s own interpretation of the SemVer spec. It exposes Version and VersionReq types that parse strings like 1.2.3-alpha.1+build5 and requirement expressions like >=1.2.3, <1.8.0, then evaluate whether a given version satisfies a requirement.
Written and maintained by David Tolnay, this is the same crate Cargo itself uses internally for dependency resolution, making it the de facto standard for any Rust tool that needs to work with version numbers or version constraints in a way that’s compatible with the crates.io ecosystem.
What You Get
VersionandVersionReqtypes withparse()methods for version strings and requirement expressions- Full support for pre-release and build-metadata identifiers per the SemVer 2.0 spec
- Comparison and ordering implementations (
Ord,PartialOrd) forVersionfollowing SemVer precedence rules - Optional
serdefeature for serializing/deserializing versions and requirements no_stdcompatibility via the default-toggleablestdfeature
Common Use Cases
- Parsing and validating version numbers supplied by users, config files, or package manifests
- Implementing dependency resolution or compatibility checks that need to evaluate whether an installed version satisfies a stated requirement
- Building Cargo-adjacent tooling (linters, dependency auditors, build scripts) that needs to interpret Cargo.toml version requirements identically to Cargo itself
- Embedding version-aware feature gating or migration logic in libraries and CLIs
Under The Hood
Architecture The crate is organized into focused modules under src/: parse.rs handles the recursive-descent parsing of both Version and VersionReq grammars, eval.rs implements the requirement-matching logic (checking a Version against a VersionReq’s comparator list), identifier.rs provides a specialized small-string type for pre-release/build-metadata identifiers to avoid heap allocation in the common case, display.rs implements Display/Debug formatting, and impls.rs/serde.rs add trait implementations (Ord, Hash, optional serde::Serialize/Deserialize). lib.rs (569 lines) defines the core Version/VersionReq/Comparator/Prerelease/BuildMetadata types and re-exports the public API.
Tech Stack Pure Rust with edition 2021, zero required dependencies, and an optional serde_core dependency gated behind the serde feature; the crate supports no_std environments by default-toggling the std feature off. A build.rs script and criterion-based benchmarks (benches/parse.rs) track parsing performance, and a fuzz/ directory holds cargo-fuzz targets for the parser, reflecting the correctness-critical nature of version parsing for the wider Cargo ecosystem.
Code Quality The crate has a dedicated tests/ directory alongside fuzz targets specifically exercising the parser against malformed input, an important quality bar given that this crate underpins Cargo’s own dependency resolution. Code is organized into small, single-responsibility modules (identifier.rs at 412 lines is the largest besides lib.rs), and the specialized Identifier type in identifier.rs shows deliberate attention to avoiding unnecessary allocations in a hot-path parsing library.
API Design The public API is small and idiomatic: Version::parse(&str) and VersionReq::parse(&str) return Result types, and VersionReq::matches(&Version) is the primary evaluation entry point, requiring no configuration to get started. Because it mirrors Cargo’s own internal version-handling exactly, the API surface is intentionally unsurprising to any Rust developer already familiar with how Cargo.toml dependency version constraints behave.
Used by 15 apps in this directory
mesh-llm
AI Agents · AI Development
Mesh LLM pools GPUs and memory across every machine you own into one OpenAI-compatible API, so agents tap distributed compute instead of a single GPU box or a metered cloud bill.
openfootmanager
Game Development
A free and open source football management simulation game built with Rust and Tauri, inspired by Football Manager.
PostHog
Ab Testing Experimentation · Analytics · Developer Tools
The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.
tabularis
Databases · Developer Tools
Open-source desktop SQL workspace with built-in PostgreSQL, MySQL, and SQLite drivers, SQL notebooks, a visual query builder, and a built-in MCP server for AI agents like Claude and Cursor.
Unsloth
AI Assistants · AI Development
Run and fine-tune LLMs, diffusion, audio and embedding models on your own hardware, from a native desktop app, a browser UI, or a Python library.
Vaultwarden
Password Manager · Security
Unofficial Bitwarden-compatible server in Rust — run the full Bitwarden ecosystem on a Raspberry Pi using every official client you already have, without the multi-container overhead.