Puzzle 3Type Conversion
 fn​ ​main​() {
 let​ x : u64 = 4_294_967_296;
 let​ y = x ​as​ u32;
 if​ x == y ​as​ u64 {
  println!(​"x equals y."​);
  } ​else​ {
  println!(​"x does not equal y."​);

Guess the Output


Try to guess what the output is before moving to the next page.


The program will display the following output:

 x does not equal y.


Rust’s as keyword is lossy. And when you use it to convert ...

Get Rust Brain Teasers now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.