Rust允许使用以下方式格式化打印变量:
fn main(){
let r:f64 = rand::random();
println!("{}",r);
}
但这不起作用:
fn main(){
println!("{}",rand::random());
}
出现了这个错误:
|
31 | println!("{}",rand::random());
| ^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the function `random`
能否直接将函数的返回值与 println!
一起使用?