let x: i32 = 4;
let y: i16 = 4;
println!("{}", x == y);
编译上述代码段时,编译器会打印以下错误:
error[E0308]: mismatched types
--> src/main.rs:5:25
|
5 | println!("{}", x == y);
| ^ expected i32, found i16
PartialEq
似乎不是针对不同类型的整数实现的.同样的情况也发生在f32
和f64
之间,PartialOrd
也是如此.这有什么原因吗?是否打算在Rust的future 版本中实施?