Reputation: 7870
I am trying to use BigInt
. My code is like this:
extern crate num;
use num::bigint::BigInt;
...
println!("{}", from_str::<BigInt>("1")); //this is line 91 in the code
In my Cargo.toml file I have the following:
[dependencies]
num = "0.1.30"
What I did seem to match what was said in this document, also this document and also an answer here on Stack Overflow.
However I got the following error:
Compiling example v0.1.0 (file:///C:/src/rust/example)
src\main.rs:91:20: 91:38 error: unresolved name `from_str` [E0425]
src\main.rs:91 println!("{}", from_str::<BigInt>("1"));
Upvotes: 5
Views: 804
Reputation: 7870
Figured out, seem like the current syntax is:
"8705702225074732811211966512111".parse::<BigInt>().unwrap();
Better yet, do the following:
match "8705702225074732811211966512111".parse::<BigInt>() {
Ok(big) => {
...
Upvotes: 5