23

So far I have seen three...

[dependencies]
crate = "1.0.0"  # I think this is an exact version match
crate = "^1.0.0" # I think this means "use that latest 1.x.x"
crate = "*"      # I think this means "use the latest"

I'd love to know for certain how to use the dependency list. It would be nice to have an authoritative source that documents the different syntaxes for dependencies.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
jocull
  • 20,008
  • 22
  • 105
  • 149
  • 2
    I don't think this question should be down-voted: the documentation on this is *not* in an obvious place. I pretty much checked every other page of documentation on `crates.io` because I looked at the correct one just to be exhaustive. – DK. Jun 14 '15 at 06:56

1 Answers1

24

See the crates.io documentation page on "Specifying Dependencies". To summarise:

  • Nothing or a caret (^) means "at least this version, until the next incompatible version".

  • A tilde (~) means "at least this version, until (but excluding) the next minor/major release". That is, ~1.2.3 will accept 1.2.X where X is at least 3, ~1.2 will accept 1.2.*, and ~1 will accept 1.*.*.

  • A wildcard (*) means "anything that looks like this". That is, 1.2.* will accept 1.2.anything (1.2.0, 1.2.7-beta, 1.2.93-dev.foo, etc. but not 1.3.0).

  • Inequalities (>=, >, <, =) mean the obvious: the version Cargo uses must satisfy the given inequality.

jocull
  • 20,008
  • 22
  • 105
  • 149
DK.
  • 55,277
  • 5
  • 189
  • 162