Puzzle 5How Long Is a String?
 const​ HELLO_WORLD : &'static str = ​"Halló heimur"​;
 
 fn​ ​main​() {
  println!(​"{} is {} characters long."​,
  HELLO_WORLD,
  HELLO_WORLD​.len​()
  );
 }

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:

 Halló heimur is 13 characters long.
images/hline.png

Discussion

Your eyes aren’t deceiving you—“Halló heimur”, contains ...

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.