Version ranges in different languages: Ruby, JavaScript, Rust.
It's clear what >
, >=
, <
, or <=
mean. But what about those other cryptic symbols?
Version | Equal To | Only Highlighted | Result |
---|---|---|---|
~1.10.100 | >=1.10.100 && <1.11.0 | 1.10.100 |
Latest patch |
~1.10 | >=1.10.0 && <2.0.0 | 1.10.0 |
|
~1 | >=1.0.0 && <2.0.0 | 1.0.0 |
|
^1.10.100 | >=1.10.100 && <2.0.0 | 1.10.100 |
Latest minor |
^0.10.100 | ~0.10.100 | 0.10.100 |
|
^0.0.100 | >=0.0.100 && <0.0.101 | 0.10.100 |
Tilde ~
Allows patch-level changes if a minor version is specified. Otherwise, allows minor-level changes.
Caret ^
Allows changes that do not modify the left-most non-zero digit. In other words, this allows patch and minor updates for versions 1.0.0 and above, patch updates for versions 0.X, and no updates for versions 0.0.X.
Version | Equal To | Only Highlighted | Result |
---|---|---|---|
~>1.10.100 | >=1.10.100 && <1.11.0 | 1.10.100 |
Latest patch |
~>1.10 | >=1.10.0 && <2.0.0 | 1.10.0 |
|
~>1 | >=1.0.0 && <2.0.0 | 1.0.0 |
Twiddle-wakka or pessimistic version constraint ~>
Allows patch-level changes if a minor version is specified. Otherwise, allows minor-level changes (same as ~
in Npm).
Version | Equal To | Only Highlighted | Result |
---|---|---|---|
~1.10.100 | >=1.10.100 && <1.11.0 | 1.10.100 |
Latest patch |
~1.10 | >=1.10.0 && <1.11.0 | 1.10.0 |
|
~1 | >=1.0.0 && <2.0.0 | 1.0.0 |
|
^1.10.100 | >=1.10.100 && <2.0.0 | 1.10.100 |
Latest minor |
^0.10.100 | ~0.10.100 | 0.10.100 |
|
^0.0.100 | >=0.0.100 && <0.0.101 | 0.0.100 |
Tilde ~
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.
Caret ^
Allows changes that do not modify the left-most non-zero digit. In other words, this allows patch and minor updates for versions 1.0.0 and above, patch updates for versions 0.X, and no updates for versions 0.0.X.
It’s worth noting that in Cargo.toml an implicit caret will be used if you don’t specify any operator.
https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-dependencies-from-cratesio