Skip to content

Instantly share code, notes, and snippets.

@Reputeless
Created December 8, 2022 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Reputeless/014f69d4913b70a46de14820317bb381 to your computer and use it in GitHub Desktop.
Save Reputeless/014f69d4913b70a46de14820317bb381 to your computer and use it in GitHub Desktop.
fn main() {
  let a = 10;
  let b : i64 = a;
  let c : i32 = a;
}
error[E0308]: mismatched types
 --> main.rs:4:17
  |
4 |   let c : i32 = a;
  |           ---   ^ expected `i32`, found `i64`
  |           |
  |           expected due to this
  |
help: you can convert an `i64` to `i32` and panic if the converted value wouldn't fit
  |
4 |   let c : i32 = a.try_into().unwrap();
  |                 ^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
exit status 1
fn main() {
  let a = 10;
  let b : i32 = a;
  let c : i64 = a;
}
error[E0308]: mismatched types
 --> main.rs:4:17
  |
4 |   let c : i64 = a;
  |           ---   ^
  |           |     |
  |           |     expected `i64`, found `i32`
  |           |     help: you can convert an `i32` to `i64`: `a.into()`
  |           expected due to this

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
exit status 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment