阐明 Cargo 的版本控制方案(CHANGELOG 与 Crates.io)

Clarify on Cargo's versioning scheme (CHANGELOG vs. Crates.io)

我对 Cargo 的版本控制方案感到困惑:CHANGELOG has latest released version 1.56 currently (though I've no idea why it also lists releases with a future date), and that's also the version cargo --version reports. That versions seems to follow Rust's version as explained in the README. However, on Crates.io 当前最新版本是 0.57.0。

那么,版本 1.56 和 0.57.0 有什么关系?

在早期,Rust 和 Cargo 的发布不一定同步。但是,自 Rust 1.13 和 Cargo 0.14 以来,Rust 版本 1.x 始终与 Cargo 版本 0.x+1 配对。自 Rust 1.26, the Cargo binary reports the same version number as Rust by doing math on its package version number.

在 crates.io 上发布的 cargo crate 仍然以 0.x+1 版本号发布,因为每个版本不一定向后兼容以前的版本(作者没有尽一切努力保持库的向后兼容性,但它们确实保持 Cargo.toml 和 Cargo.lock 文件的兼容性),Cargo 认为 0.y 和 0.y+1 不兼容(这是对 Semantic Versioning 的扩展)。

So, how do versions 1.56 and 0.57.0 relate?

Rust 1.56.0 与 Cargo 二进制 1.56.0 一起发布,它使用 Cargo 库 0.57.0。

though I've no idea why it also lists releases with a future date

Rust 和 Cargo 的 master 分支都包含 nightly channel,通常比当前稳定版本早 2 个版本。维护者可以在实际发布之前添加发布说明,这样他们就不需要一次写完;这意味着未来版本的发行说明可能不完整。由于每 6 周发布一次,未来版本的发布日期是可以预测的,因此他们可以在发布说明中写下这些日期,并确信这将是实际发布日期。