我开始学习 Rust,尝试了这个程序:
fn main() {
let a = 5;
let b = 5.5;
let k = a + b;
println!("{}", k);
}
并且它显示了这个错误:
error[E0277]: cannot add a float to an integer
--> src/main.rs:4:16
|
4 | let k = a + b;
| ^ no implementation for `{integer} + {float}`
|
= help: the trait `std::ops::Add<{float}>` is not implemented for `{integer}`
代码有错误吗?