我想,如文档中所描述来构建一个简单guessing-game。
use std::io;
//use rand::Rng; is not included
fn main() {
println!("Guess the number!");
let secret_number = rand::thread_rng().gen_range(1, 101);
println!("The secret number is: {}", secret_number);
println!("Please input your guess.");
let mut guess = String::new();
io::stdin().read_line(&mut guess)
.expect("Failed to read line");
println!("You guessed: {}", guess);
}
上面的代码将无法编译由于缺少rand::Rng
库(附注注释)。
问题是,cargo build
命令的结果包含不可读的字符:
我使用CentOS的7,防锈版本1.32.0和货物版本1.32.0。我能之前运行cargo-build
后,以验证终端编码,它没有改变。
是否有人可以解释这种现象?
您可以使用cargo build --color=never
不使用的颜色。
为了帮助您解决问题,同时保持颜色,我们需要更多的信息。例如。您所使用的终端模拟器,你有什么语言环境,等等。