【发布时间】:2018-07-16 00:05:16
【问题描述】:
我有以下代码:
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)。如果我没有具体的答案,我不在乎技术细节、什么或为什么。如何编译此代码以显示浮点结果?
【问题讨论】:
标签: rust