相关疑难解决方法(0)

在Rust中,如何在BigInt上使用已实现的特征FromStr?

我想让这个程序编译:

extern crate num;
use num::bigint::BigInt;
use std::from_str::FromStr;

fn main () {
    println!("{}", BigInt::from_str("1"));
}
Run Code Online (Sandbox Code Playgroud)

但输出rustc是

testing.rs:6:20: 6:36 error: unresolved name `BigInt::from_str`.
testing.rs:6     println!("{}", BigInt::from_str("1"));
                                ^~~~~~~~~~~~~~~~
note: in expansion of format_args!
<std macros>:2:23: 2:77 note: expansion site
<std macros>:1:1: 3:2 note: in expansion of println!
testing.rs:6:5: 6:43 note: expansion site
error: aborting due to previous error
Run Code Online (Sandbox Code Playgroud)

我怀疑我做了一些非常错误的事情,但我试图搜索示例并尝试了一系列不同的更改,而我尝试过的任何工作都没有.

如何更改源代码以便编译?

rust

4
推荐指数
1
解决办法
1793
查看次数

标签 统计

rust ×1