How to parse BigInt from a num box?

I am trying to use BigInt. My code is as follows:

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"

That I seem to be consistent with what was said in this document , also this document , as well as the answer here about the 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"));
+4
source share
1 answer

It appears that the current syntax seems to be:

"8705702225074732811211966512111".parse::<BigInt>().unwrap();

Better yet, do the following:

match "8705702225074732811211966512111".parse::<BigInt>() {
    Ok(big) => {
        ...
+4
source

Source: https://habr.com/ru/post/1624013/


All Articles