我的箱子有一个小问题:这段代码有效:
fn main() {
println!("Celsius to farenheit");
print!("Insert Celsius: ");
let celsius: f32 = read!();
println!("Celsius to Farenheit is: {}", cel_to_far(celsius));
}
但是如果我使用text_io手册中的内容:
fn main() {
println!("Celsius to farenheit");
let celsius: f32 = read!("Insert Celsius: {}!");
println!("Celsius to Farenheit is: {}", cel_to_far(celsius));
}
它惊慌失措:
Celsius to farenheit
6
thread 'main' panicked at src/main.rs:4:24:
called `Result::unwrap()` on an `Err` value: UnexpectedValue(73, Some(54))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
这不是,我认为我遵循了正确的说明: