docs(manifest): Describe version syntax

This is modeled off of `resolver.md` and is prep for moving it to other
places.
This commit is contained in:
Ed Page 2024-10-08 15:41:32 -05:00
parent 5d45b31cda
commit c64a063fad

View File

@ -92,6 +92,20 @@ a keyword. [crates.io] imposes even more restrictions, such as:
### The `version` field
The `version` field is formatted according to the [SemVer] specification:
Versions must have three numeric parts,
the major version, the minor version, and the patch version.
A pre-release part can be added after a dash such as `1.0.0-alpha`.
The pre-release part may be separated with periods to distinguish separate
components. Numeric components will use numeric comparison while
everything else will be compared lexicographically.
For example, `1.0.0-alpha.11` is higher than `1.0.0-alpha.4`.
A metadata part can be added after a plus, such as `1.0.0+21AF26D3`.
This is for informational purposes only and is generally ignored by Cargo.
Cargo bakes in the concept of [Semantic
Versioning](https://semver.org/), so make sure you follow some basic rules:
@ -103,7 +117,6 @@ Versioning](https://semver.org/), so make sure you follow some basic rules:
* After 1.0.0, dont add any new public API (no new `pub` anything) in patch-level
versions. Always increment the minor version if you add any new `pub` structs,
traits, fields, types, functions, methods or anything else.
* Use version numbers with three numeric parts such as 1.0.0 rather than 1.0.
See the [Resolver] chapter for more information on how Cargo uses versions to
resolve dependencies, and for guidelines on setting your own version. See the
@ -114,6 +127,7 @@ This field is optional and defaults to `0.0.0`. The field is required for publi
> **MSRV:** Before 1.75, this field was required
[SemVer]: https://semver.org
[Resolver]: resolver.md
[SemVer compatibility]: semver.md