Comments
// Single line comment
/// Doc comments
/* Multiline
comment */
Strings
'C'; '\''; '\n'; '\u{7FFF}'; // Characters
"foo \"bar\" baz"; // String
r##"foo #"bar"# baz"##; // Raw string with # pairs
b'C'; b'\''; b'\n'; // Bytes
b"foo \"bar\" baz"; // Byte string
br##"foo #"bar"# baz"##; // Raw byte string with # pairs
Numbers
0xff_u8; // type u8
0o70_i16; // type i16
0b1111_1111_1001_0000_i32; // type i32
123.0f64; // type f64
0.1f64; // type f64
0.1f32; // type f32
12E+99_f64; // type f64
Booleans
true; false;
Functions and macros
println!("x is {}", x);
fn next_two(x: i32) -> (i32, i32) { (x + 1, x + 2) }
next_two(5);
vec![1, 2, 3];
Attributes
#![warn(unstable)]
#[test]
fn a_test() {
// ...
}
Closure parameters and bitwise OR
let x = a | b;
let y = c || d;
let add_one = |x: i32| -> i32 { 1i + x };
let printer = || { println!("x is: {}", x); };