Skip to main content

Crate semver_diff

Crate semver_diff 

Source
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 a and b, or None if they compare equal.
diff_str
Parse a and b as semver::Versions and return their diff.