[英]Why does the output of cargo build contain unreadable characters when the build fails?
我正在嘗試按照文檔中的描述構建一個簡單的猜謎游戲 。
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,Rust版本1.32.0和Cargo版本1.32.0。 我能夠在運行cargo-build
之前和之后驗證終端編碼,並且沒有更改。
有人可以解釋這種行為嗎?
您可以使用cargo build --color=never
不使用顏色。
為了幫助您在保持色彩的同時解決問題,我們需要更多信息。 例如。 您使用哪種終端仿真器,您的語言環境是什么,等等。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.