Reputation: 1778
Is that the same
[dependencies]
for_each = "0.1"
as
[dependencies]
for_each = "0.1.2"
And
[dependencies]
for_each = "~0.1"
From description, it looks like the same, but from experimentation I am getting inconsistent results.
What is the subtle difference between those 3 variants of requiring dependencies?
It looks like ranges are:
0.1 := >=0.1.0, <0.2.0
0.1.2 := >=0.1.2, <0.2.0
~0.1 := >=0.1.0, <0.2.0
Right?
From these, it's clear that 0.1
and ~0.1
have the same range.
But I encountered a situation when 0.1
and ~0.1
give very different results.
Some subtle difference beyond ranges exists, and I don't understand what is that.
Upvotes: 1
Views: 154
Reputation: 22371
0.1 := >=0.1.0, <0.2.0
0.1.2 := >=0.1.2, <0.2.0
~0.1 := >=0.1.0, <0.2.0
More details at https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html.
Without the tilde, version compatibility is determined following the SemVer rules.
Cargo extended SemVer for <1.0.0
versions:
Cargo considers
0.x.y
to be compatible with0.x.z
, wherey ≥ z
andx > 0
.
On the other hand, Tilde Requirements seems to be something defined by Cargo:
Tilde requirements specify a minimal version with some ability to update. If you specify a major, minor, and patch version or only a major and minor version, only patch-level changes are allowed. If you only specify a major version, then minor- and patch-level changes are allowed.
Upvotes: 1