我有以下代码:
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篇).如果我没有一个具体的答案,我不关心技术细节,也不关心什么或为什么.如何编译此代码,使其显示浮点结果?