A literal is syntax for writing a value directly. In `let a = 10;`, `10` supplies the value for a variable binding. Numeric literals can carry a type suffix: `30i32` and `30_i32` both specify `i32`; the underscore improves readability without changing the value. section 2.2.1
Integer literals can use binary (`0b11`), octal (`0o36`), or hexadecimal (`0x12C`) notation. These values are 3, 30, and 300 in decimal. The notation changes how you write the integer, not the value it represents. section 2.3.2
Listing 2.4 Using base 2, base 8, and base 16 numeric literals
fn main() {
let three = 0b11; #1
let thirty = 0o36; #2
let three_hundred = 0x12C; #3
println!("base 10: {} {} {}", three, thirty, three_hundred);
println!("base 2: {:b} {:b} {:b}", three, thirty, three_hundred);
println!("base 8: {:o} {:o} {:o}", three, thirty, three_hundred);
println!("base 16: {:x} {:x} {:x}", three, thirty, three_hundred);
}
Compare the three integer-literal prefixes with the formatting options that print each value in different bases. section 2.3.2
A value with named fields can also be initialized directly. `Complex { re: 2.1, im: -1.2 }` assigns its real and imaginary fields. `Complex::new(11.1, 22.2)` is an alternative supplied by the type’s library; `new()` is a convention, not literal syntax built into Rust. section 2.3.4
Listing 2.6 Calculating values with complex numbers
use num::complex::Complex; #1
fn main() {
let a = Complex { re: 2.1, im: -1.2 }; #2
let b = Complex::new(11.1, 22.2); #3
let result = a + b;
println!("{} + {}i", result.re, result.im) #4
}
See field-based initialization and `Complex::new()` side by side in a program that adds two complex numbers. section 2.3.4
Quotes distinguish another pair of forms: `b'a'` creates one `u8` byte, while `b"a"` creates a one-byte slice. section 10.6





