<分区>
我有以下代码:
struct Stuff {
thing: i8
}
fn main(){
let theStuff = Stuff { thing: 1 };
println!("{}", theStuff.thing * 1.5);
}
我在编译时得到以下信息:
error[E0277]: the trait bound `i8: std::ops::Mul<{float}>` is not satisfied
--> IntFloatMultiply.rs:7:32
|
7 | println!("{}", theStuff.thing * 1.5);
| ^ no implementation for `i8 * {float}`
|
= help: the trait `std::ops::Mul<{float}>` is not implemented for `i8`
我已经阅读了一些其他帖子,其中包括一堆让我头疼的东西(包括 https://stackoverflow.com/a/44552464/1678392 )。如果我没有具体的答案可以开始,我不关心技术细节,什么或为什么。我如何编译此代码以显示 float 结果?