composer-semver 0.2.0

A faithful Rust port of composer/semver: Composer-flavored Version, Constraint, and Stability — normalize, compare, and match version constraints.
Documentation

composer-semver

A faithful Rust port of composer/semver — the Composer-flavored version normalization, comparison, and constraint algebra that PHP's Composer itself uses.

use composer_semver::{Constraint, Version};

let v = Version::parse("v1.2.3-beta2").unwrap();
let c = Constraint::parse("^1.2").unwrap();
assert!(c.matches(&v));

It mirrors Composer's VersionParser::normalize, Comparator::compare, and VersionParser::parseConstraints against a pinned upstream commit (recorded in src/version.rs), and the upstream data-provider cases are committed as Layer 1 conformance fixtures:

cargo test -p composer-semver

What's covered

  • Version — normalize (v1.21.2.0.0), branch versions (dev-*), stability detection, and Composer-correct comparison/ordering.
  • Constraint^, ~, */x, hyphen ranges, >=/</!=, || unions, stability flags, and dev-<branch> references; matches, lower_bound/upper_bound, and intersects.
  • Stabilitydev < alpha < beta < RC < stable.

Part of the composer-rs workspace — shared Composer-domain crates for the cresset-tools family (bougie, sconce).

License

EUPL-1.2.