This commit is contained in:
Esteban Küber 2019-04-21 15:57:00 -07:00
parent 4b1297baf7
commit 4e84b619f4
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,8 @@
fn main() {
let array = [1, 2, 3];
test(array.len()); //~ ERROR mismatched types
}
fn test(length: u32) {
println!("{}", length);
}

View File

@ -0,0 +1,13 @@
error[E0308]: mismatched types
--> $DIR/len.rs:3:10
|
LL | test(array.len());
| ^^^^^^^^^^^ expected u32, found usize
help: you can convert an `usize` to `u32` or panic if it the converted value wouldn't fit
|
LL | test(array.len().try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.