Expand description
§semver-diff — the release-type difference between two versions
Given two semver::Versions, report what kind of change separates them — a
major, minor, or patch bump, or one of their prerelease variants. A faithful Rust
port of node-semver’s diff (and the
semver-diff npm package), useful
for update notifiers, changelog tooling, and dependency dashboards.
use semver::Version;
use semver_diff::{diff, Difference};
assert_eq!(diff(&Version::new(1, 0, 0), &Version::new(1, 0, 1)), Some(Difference::Patch));
assert_eq!(diff(&Version::new(1, 0, 0), &Version::new(2, 0, 0)), Some(Difference::Major));
assert_eq!(diff(&Version::new(1, 2, 3), &Version::new(1, 2, 3)), None);Or work straight from strings with diff_str:
assert_eq!(semver_diff::diff_str("1.0.0", "1.1.0-rc.1").unwrap(), Some(semver_diff::Difference::PreMinor));Enums§
- Difference
- The kind of change between two versions.
Functions§
- diff
- The release-type difference between
aandb, orNoneif they compare equal. - diff_
str - Parse
aandbassemver::Versions and return theirdiff.