我正在尝试使用 BigInt 。我的代码如下:
BigInt
extern crate num; use num::bigint::BigInt; ... println!("{}", from_str::<BigInt>("1")); //this is line 91 in the code
在我的货物中。toml文件我有以下内容:
[dependencies] num = "0.1.30"
我的所作所为似乎与 this document , also this document 而且 an answer here on Stack Overflow .
然而,我得到了以下错误:
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"));
经过计算,当前的语法似乎是:
"8705702225074732811211966512111".parse::<BigInt>().unwrap();
更好的做法是:
match "8705702225074732811211966512111".parse::<BigInt>() { Ok(big) => { ...