Literal expressions

The simplest of Rust's expressions are the ones where we just write out the representation of the value we want. For example, when Rust sees 2 it knows we are asking it for the number 2. Similarly, when Rust sees "Hello, world!" it knows we're asking it to produce the sequence of letters that spells out Hello, world!

Rust recognizes the following literal expressions:

  • Numbers
  • Quoted text
  • Byte sequences
  • Single Unicode points
  • Single bytes
  • Boolean values

Numbers can be written as integers or decimal numbers or in engineering notation, and there are a few variants for quoted text and byte sequences, too. Boolean values are written as either true or false. In this book, we're not going to need any of the variants of quoted text, and we won't need byte sequences at all, so we won't go into those in more detail. See https://doc.rust-lang.org/ if you're curious.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.181.36