在Java中,我可以做到这一点.
int diff = 'Z' - 'A'; // 25
我也试过同样的方法:
fn main() {
'Z' - 'A';
}
但编者抱怨:
error[E0369]: binary operation `-` cannot be applied to type `char`
--> src/main.rs:2:5
|
2 | 'Z' - 'A';
| ^^^^^^^^^
|
= note: an implementation of `std::ops::Sub` might be missing for `char`
我怎样才能在Rust 的情况下进行同样的操作?