fn main() {
let array = [1, 2, 3];
test(array.len());
}
fn test(length: u32) {
println!("{}", length);
}
Gives the following compile time error on rustc 1.22.1 (stable):
Compiling playground v0.0.1 (file:///playground)
error[E0308]: mismatched types
--> src/main.rs:3:10
|
3 | test(array.len());
| ^^^^^^^^^^^ expected u32, found usize
|
= help: here are some functions which might fulfill your needs:
- .count_ones()
- .count_zeros()
- .leading_zeros()
- .trailing_zeros()
error: aborting due to previous error
error: Could not compile `playground`.
I'm assuming there's a lot of nuance in the engine that gives suggestion so I don't know how I would personally codify the rules (and even if casting as a u32 is always appropriate since I guess it could overflow) but I do know that the suggestions definitely do not point me in the right direction.
Gives the following compile time error on rustc 1.22.1 (stable):
I'm assuming there's a lot of nuance in the engine that gives suggestion so I don't know how I would personally codify the rules (and even if casting as a u32 is always appropriate since I guess it could overflow) but I do know that the suggestions definitely do not point me in the right direction.