Automatically replace `'*'` in Cargo.toml with latest/current version?

When I'm hacking on my little project, I usually just use somedep = '*'. I wish it automatically turned into the latest version or something like that. Is there any tool to do that?


For vs code there is an extension called crates that prints the latest version next to the dependency, and also allows you to choose from existing versions.

1 Like

That's neat. But I'm a vimer, I really care only about getting rid of * there quickly. :slight_smile:

the 'cargo edit' and 'cargo update' plugins, probably does what you want. Add with the current version easily, and update as you go.


I might be missing something, but they don't seem to do what I want. I want '*' to be replaced with '0.4.2' in Cargo.toml, not just get new deps in Cargo.lock

Sorry, two clarifications:

  • I understood what you wanted; I was suggesting an alternate workflow (where you never start with the *) that might achieve the same effect (not really caring about the actual value to start with, because cargo add just puts it there for you), but that wasn't clear.
  • I should have talked about cargo upgrade rather than cargo update; they're easy to mix up.