Puzzle 13Reverse the Polarity of the Neutron Flow
 fn​ ​display_neutron_flow​(polarity: isize) {
  println!(
 "Neutron Flow is {}"​,
 if​ polarity < 0 { ​"reversed"​} ​else​ { ​"normal"​ }
  );
 }
 
 fn​ ​main​() {
 let​ polarity = 1;
  {
 let​ polarity = polarity ​-​ 2;
 display_neutron_flow​(polarity);
  }
 display_neutron_flow​(polarity);
 }

Guess the Output

images/aside-icons/important.png

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

images/hline.png

The program will display the following output:

 Neutron Flow is reversed
 Neutron ...

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.