Reputation: 91
I'm trying to use the crate 'num' in my project in Rust (I'm a total newbie to this language), so my Cargo.toml is now:
[package]
name = "hello_world"
version = "0.0.1"
authors = [ "Vini" ]
[dependencies]
time = "*"
num = "*"
but when I run:
cargo run
I get this compile error:
/.cargo/registry/src/github.com-0a35038f75765ae4/num-0.0.6/src/bigint.rs:66:16: 66:19 error: expected identifier, found keyword `mod`
/.cargo/registry/src/github.com-0a35038f75765ae4/num-0.0.6/src/bigint.rs:66 use std::str::{mod, FromStr};
^~~
/.cargo/registry/src/github.com-0a35038f75765ae4/num-0.0.6/src/bigint.rs:80:27: 80:28 error: expected one of `(`, `+`, `::`, `;`, `<`, or `]`, found `,`
/.cargo/registry/src/github.com-0a35038f75765ae4/num-0.0.6/src/bigint.rs:80 static ZERO_VEC: [BigDigit, ..1] = [ZERO_BIG_DIGIT];
^
Could not compile `num`.
I have no idea what this actually means, am I using cargo wrong? Is this version of 'num' incompatible with cargo?
I have cargo version:
cargo 0.4.0-nightly (15b497b 2015-07-08) (built 2015-07-10)
and rust compiler:
rustc 1.2.0 (082e47636 2015-08-03)
Upvotes: 1
Views: 1000
Reputation: 430673
Your Cargo.lock file contains a reference to an old version of a crate (a very old one, in this case). Run cargo update
to get the newest version.
When building your code, you communicate your desired version restrictions to Cargo using the Cargo.toml file. This lets you say things like "at least this version" or "only this exact version" or "any bug fix to this version".
Cargo takes your restrictions and the currently available versions and computes the newest set of versions that fits or tells you if it couldn't. It then saves all of that data into the Cargo.lock file.
The Cargo.lock file sticks around so that versions of libraries aren't changing willy-nilly under you. You can run cargo update
to redo the process and get the newest versions.
If you are producing a library, that's where the story ends. If you are producing a binary, you should check in the lockfile to source control, as that's how you communicate to other users of the code exactly what versions should be used. When you deploy releases of your code, you can then be sure that the same versions are being used in production as development.
Upvotes: 3