5 * `as`: primitive casting, or disambiguating the specific trait containing an item. See [Casting Between Types (`as`)], [Universal Function Call Syntax (Angle-bracket Form)], [Associated Types].
6 * `break`: break out of loop. See [Loops (Ending Iteration Early)].
7 * `const`: constant items and constant raw pointers. See [`const` and `static`], [Raw Pointers].
8 * `continue`: continue to next loop iteration. See [Loops (Ending Iteration Early)].
9 * `crate`: external crate linkage. See [Crates and Modules (Importing External Crates)].
10 * `else`: fallback for `if` and `if let` constructs. See [`if`], [`if let`].
11 * `enum`: defining enumeration. See [Enums].
12 * `extern`: external crate, function, and variable linkage. See [Crates and Modules (Importing External Crates)], [Foreign Function Interface].
13 * `false`: boolean false literal. See [Primitive Types (Booleans)].
14 * `fn`: function definition and function pointer types. See [Functions].
15 * `for`: iterator loop, part of trait `impl` syntax, and higher-ranked lifetime syntax. See [Loops (`for`)], [Method Syntax].
16 * `if`: conditional branching. See [`if`], [`if let`].
17 * `impl`: inherent and trait implementation blocks. See [Method Syntax].
18 * `in`: part of `for` loop syntax. See [Loops (`for`)].
19 * `let`: variable binding. See [Variable Bindings].
20 * `loop`: unconditional, infinite loop. See [Loops (`loop`)].
21 * `match`: pattern matching. See [Match].
22 * `mod`: module declaration. See [Crates and Modules (Defining Modules)].
23 * `move`: part of closure syntax. See [Closures (`move` closures)].
24 * `mut`: denotes mutability in pointer types and pattern bindings. See [Mutability].
25 * `pub`: denotes public visibility in `struct` fields, `impl` blocks, and modules. See [Crates and Modules (Exporting a Public Interface)].
26 * `ref`: by-reference binding. See [Patterns (`ref` and `ref mut`)].
27 * `return`: return from function. See [Functions (Early Returns)].
28 * `Self`: implementor type alias. See [Traits].
29 * `self`: method subject. See [Method Syntax (Method Calls)].
30 * `static`: global variable. See [`const` and `static` (`static`)].
31 * `struct`: structure definition. See [Structs].
32 * `trait`: trait definition. See [Traits].
33 * `true`: boolean true literal. See [Primitive Types (Booleans)].
34 * `type`: type alias, and associated type definition. See [`type` Aliases], [Associated Types].
35 * `unsafe`: denotes unsafe code, functions, traits, and implementations. See [Unsafe].
36 * `use`: import symbols into scope. See [Crates and Modules (Importing Modules with `use`)].
37 * `where`: type constraint clauses. See [Traits (`where` clause)].
38 * `while`: conditional loop. See [Loops (`while`)].
40 ## Operators and Symbols
42 * `!` (`ident!(…)`, `ident!{…}`, `ident![…]`): denotes macro expansion. See [Macros].
43 * `!` (`!expr`): bitwise or logical complement. Overloadable (`Not`).
44 * `!=` (`var != expr`): nonequality comparison. Overloadable (`PartialEq`).
45 * `%` (`expr % expr`): arithmetic remainder. Overloadable (`Rem`).
46 * `%=` (`var %= expr`): arithmetic remainder & assignment. Overloadable (`RemAssign`).
47 * `&` (`expr & expr`): bitwise and. Overloadable (`BitAnd`).
48 * `&` (`&expr`): borrow. See [References and Borrowing].
49 * `&` (`&type`, `&mut type`, `&'a type`, `&'a mut type`): borrowed pointer type. See [References and Borrowing].
50 * `&=` (`var &= expr`): bitwise and & assignment. Overloadable (`BitAndAssign`).
51 * `&&` (`expr && expr`): logical and.
52 * `*` (`expr * expr`): arithmetic multiplication. Overloadable (`Mul`).
53 * `*` (`*expr`): dereference.
54 * `*` (`*const type`, `*mut type`): raw pointer. See [Raw Pointers].
55 * `*=` (`var *= expr`): arithmetic multiplication & assignment. Overloadable (`MulAssign`).
56 * `+` (`expr + expr`): arithmetic addition. Overloadable (`Add`).
57 * `+` (`trait + trait`, `'a + trait`): compound type constraint. See [Traits (Multiple Trait Bounds)].
58 * `+=` (`var += expr`): arithmetic addition & assignment. Overloadable (`AddAssign`).
59 * `,`: argument and element separator. See [Attributes], [Functions], [Structs], [Generics], [Match], [Closures], [Crates and Modules (Importing Modules with `use`)].
60 * `-` (`expr - expr`): arithmetic subtraction. Overloadable (`Sub`).
61 * `-` (`- expr`): arithmetic negation. Overloadable (`Neg`).
62 * `-=` (`var -= expr`): arithmetic subtraction & assignment. Overloadable (`SubAssign`).
63 * `->` (`fn(…) -> type`, `|…| -> type`): function and closure return type. See [Functions], [Closures].
64 * `-> !` (`fn(…) -> !`, `|…| -> !`): diverging function or closure. See [Diverging Functions].
65 * `.` (`expr.ident`): member access. See [Structs], [Method Syntax].
66 * `..` (`..`, `expr..`, `..expr`, `expr..expr`): right-exclusive range literal.
67 * `..` (`..expr`): struct literal update syntax. See [Structs (Update syntax)].
68 * `..` (`variant(x, ..)`, `struct_type { x, .. }`): "and the rest" pattern binding. See [Patterns (Ignoring bindings)].
69 * `...` (`...expr`, `expr...expr`) *in an expression*: inclusive range expression. See [Iterators].
70 * `...` (`expr...expr`) *in a pattern*: inclusive range pattern. See [Patterns (Ranges)].
71 * `/` (`expr / expr`): arithmetic division. Overloadable (`Div`).
72 * `/=` (`var /= expr`): arithmetic division & assignment. Overloadable (`DivAssign`).
73 * `:` (`pat: type`, `ident: type`): constraints. See [Variable Bindings], [Functions], [Structs], [Traits].
74 * `:` (`ident: expr`): struct field initializer. See [Structs].
75 * `:` (`'a: loop {…}`): loop label. See [Loops (Loops Labels)].
76 * `;`: statement and item terminator.
77 * `;` (`[…; len]`): part of fixed-size array syntax. See [Primitive Types (Arrays)].
78 * `<<` (`expr << expr`): left-shift. Overloadable (`Shl`).
79 * `<<=` (`var <<= expr`): left-shift & assignment. Overloadable (`ShlAssign`).
80 * `<` (`expr < expr`): less-than comparison. Overloadable (`PartialOrd`).
81 * `<=` (`var <= expr`): less-than or equal-to comparison. Overloadable (`PartialOrd`).
82 * `=` (`var = expr`, `ident = type`): assignment/equivalence. See [Variable Bindings], [`type` Aliases], generic parameter defaults.
83 * `==` (`var == expr`): equality comparison. Overloadable (`PartialEq`).
84 * `=>` (`pat => expr`): part of match arm syntax. See [Match].
85 * `>` (`expr > expr`): greater-than comparison. Overloadable (`PartialOrd`).
86 * `>=` (`var >= expr`): greater-than or equal-to comparison. Overloadable (`PartialOrd`).
87 * `>>` (`expr >> expr`): right-shift. Overloadable (`Shr`).
88 * `>>=` (`var >>= expr`): right-shift & assignment. Overloadable (`ShrAssign`).
89 * `@` (`ident @ pat`): pattern binding. See [Patterns (Bindings)].
90 * `^` (`expr ^ expr`): bitwise exclusive or. Overloadable (`BitXor`).
91 * `^=` (`var ^= expr`): bitwise exclusive or & assignment. Overloadable (`BitXorAssign`).
92 * `|` (`expr | expr`): bitwise or. Overloadable (`BitOr`).
93 * `|` (`pat | pat`): pattern alternatives. See [Patterns (Multiple patterns)].
94 * `|` (`|…| expr`): closures. See [Closures].
95 * `|=` (`var |= expr`): bitwise or & assignment. Overloadable (`BitOrAssign`).
96 * `||` (`expr || expr`): logical or.
97 * `_`: "ignored" pattern binding. See [Patterns (Ignoring bindings)].
101 <!-- Various bits of standalone stuff. -->
103 * `'ident`: named lifetime or loop label. See [Lifetimes], [Loops (Loops Labels)].
104 * `…u8`, `…i32`, `…f64`, `…usize`, …: numeric literal of specific type.
105 * `"…"`: string literal. See [Strings].
106 * `r"…"`, `r#"…"#`, `r##"…"##`, …: raw string literal, escape characters are not processed. See [Reference (Raw String Literals)].
107 * `b"…"`: byte string literal, constructs a `[u8]` instead of a string. See [Reference (Byte String Literals)].
108 * `br"…"`, `br#"…"#`, `br##"…"##`, …: raw byte string literal, combination of raw and byte string literal. See [Reference (Raw Byte String Literals)].
109 * `'…'`: character literal. See [Primitive Types (`char`)].
110 * `b'…'`: ASCII byte literal.
111 * `|…| expr`: closure. See [Closures].
113 <!-- Path-related syntax -->
115 * `ident::ident`: path. See [Crates and Modules (Defining Modules)].
116 * `::path`: path relative to the crate root (*i.e.* an explicitly absolute path). See [Crates and Modules (Re-exporting with `pub use`)].
117 * `self::path`: path relative to the current module (*i.e.* an explicitly relative path). See [Crates and Modules (Re-exporting with `pub use`)].
118 * `super::path`: path relative to the parent of the current module. See [Crates and Modules (Re-exporting with `pub use`)].
119 * `type::ident`, `<type as trait>::ident`: associated constants, functions, and types. See [Associated Types].
120 * `<type>::…`: associated item for a type which cannot be directly named (*e.g.* `<&T>::…`, `<[T]>::…`, *etc.*). See [Associated Types].
121 * `trait::method(…)`: disambiguating a method call by naming the trait which defines it. See [Universal Function Call Syntax].
122 * `type::method(…)`: disambiguating a method call by naming the type for which it's defined. See [Universal Function Call Syntax].
123 * `<type as trait>::method(…)`: disambiguating a method call by naming the trait _and_ type. See [Universal Function Call Syntax (Angle-bracket Form)].
127 * `path<…>` (*e.g.* `Vec<u8>`): specifies parameters to generic type *in a type*. See [Generics].
128 * `path::<…>`, `method::<…>` (*e.g.* `"42".parse::<i32>()`): specifies parameters to generic type, function, or method *in an expression*.
129 * `fn ident<…> …`: define generic function. See [Generics].
130 * `struct ident<…> …`: define generic structure. See [Generics].
131 * `enum ident<…> …`: define generic enumeration. See [Generics].
132 * `impl<…> …`: define generic implementation.
133 * `for<…> type`: higher-ranked lifetime bounds.
134 * `type<ident=type>` (*e.g.* `Iterator<Item=T>`): a generic type where one or more associated types have specific assignments. See [Associated Types].
138 * `T: U`: generic parameter `T` constrained to types that implement `U`. See [Traits].
139 * `T: 'a`: generic type `T` must outlive lifetime `'a`. When we say that a type 'outlives' the lifetime, we mean that it cannot transitively contain any references with lifetimes shorter than `'a`.
140 * `T : 'static`: The generic type `T` contains no borrowed references other than `'static` ones.
141 * `'b: 'a`: generic lifetime `'b` must outlive lifetime `'a`.
142 * `T: ?Sized`: allow generic type parameter to be a dynamically-sized type. See [Unsized Types (`?Sized`)].
143 * `'a + trait`, `trait + trait`: compound type constraint. See [Traits (Multiple Trait Bounds)].
145 <!-- Macros and attributes -->
147 * `#[meta]`: outer attribute. See [Attributes].
148 * `#![meta]`: inner attribute. See [Attributes].
149 * `$ident`: macro substitution. See [Macros].
150 * `$ident:kind`: macro capture. See [Macros].
151 * `$(…)…`: macro repetition. See [Macros].
155 * `//`: line comment. See [Comments].
156 * `//!`: inner line doc comment. See [Comments].
157 * `///`: outer line doc comment. See [Comments].
158 * `/*…*/`: block comment. See [Comments].
159 * `/*!…*/`: inner block doc comment. See [Comments].
160 * `/**…*/`: outer block doc comment. See [Comments].
162 <!-- Various things involving parens and tuples -->
164 * `()`: empty tuple (*a.k.a.* unit), both literal and type.
165 * `(expr)`: parenthesized expression.
166 * `(expr,)`: single-element tuple expression. See [Primitive Types (Tuples)].
167 * `(type,)`: single-element tuple type. See [Primitive Types (Tuples)].
168 * `(expr, …)`: tuple expression. See [Primitive Types (Tuples)].
169 * `(type, …)`: tuple type. See [Primitive Types (Tuples)].
170 * `expr(expr, …)`: function call expression. Also used to initialize tuple `struct`s and tuple `enum` variants. See [Functions].
171 * `ident!(…)`, `ident!{…}`, `ident![…]`: macro invocation. See [Macros].
172 * `expr.0`, `expr.1`, …: tuple indexing. See [Primitive Types (Tuple Indexing)].
174 <!-- Bracey things -->
176 * `{…}`: block expression.
177 * `Type {…}`: `struct` literal. See [Structs].
179 <!-- Brackety things -->
181 * `[…]`: array literal. See [Primitive Types (Arrays)].
182 * `[expr; len]`: array literal containing `len` copies of `expr`. See [Primitive Types (Arrays)].
183 * `[type; len]`: array type containing `len` instances of `type`. See [Primitive Types (Arrays)].
184 * `expr[expr]`: collection indexing. Overloadable (`Index`, `IndexMut`).
185 * `expr[..]`, `expr[a..]`, `expr[..b]`, `expr[a..b]`: collection indexing pretending to be collection slicing, using `Range`, `RangeFrom`, `RangeTo`, `RangeFull` as the "index".
187 [`const` and `static` (`static`)]: const-and-static.html#static
188 [`const` and `static`]: const-and-static.html
189 [`if let`]: if-let.html
191 [`type` Aliases]: type-aliases.html
192 [Associated Types]: associated-types.html
193 [Attributes]: attributes.html
194 [Casting Between Types (`as`)]: casting-between-types.html#as
195 [Closures (`move` closures)]: closures.html#move-closures
196 [Closures]: closures.html
197 [Comments]: comments.html
198 [Crates and Modules (Defining Modules)]: crates-and-modules.html#defining-modules
199 [Crates and Modules (Exporting a Public Interface)]: crates-and-modules.html#exporting-a-public-interface
200 [Crates and Modules (Importing External Crates)]: crates-and-modules.html#importing-external-crates
201 [Crates and Modules (Importing Modules with `use`)]: crates-and-modules.html#importing-modules-with-use
202 [Crates and Modules (Re-exporting with `pub use`)]: crates-and-modules.html#re-exporting-with-pub-use
203 [Diverging Functions]: functions.html#diverging-functions
205 [Foreign Function Interface]: ffi.html
206 [Functions (Early Returns)]: functions.html#early-returns
207 [Functions]: functions.html
208 [Generics]: generics.html
209 [Iterators]: iterators.html
210 [Lifetimes]: lifetimes.html
211 [Loops (`for`)]: loops.html#for
212 [Loops (`loop`)]: loops.html#loop
213 [Loops (`while`)]: loops.html#while
214 [Loops (Ending Iteration Early)]: loops.html#ending-iteration-early
215 [Loops (Loops Labels)]: loops.html#loop-labels
216 [Macros]: macros.html
218 [Method Syntax (Method Calls)]: method-syntax.html#method-calls
219 [Method Syntax]: method-syntax.html
220 [Mutability]: mutability.html
221 [Operators and Overloading]: operators-and-overloading.html
222 [Patterns (`ref` and `ref mut`)]: patterns.html#ref-and-ref-mut
223 [Patterns (Bindings)]: patterns.html#bindings
224 [Patterns (Ignoring bindings)]: patterns.html#ignoring-bindings
225 [Patterns (Multiple patterns)]: patterns.html#multiple-patterns
226 [Patterns (Ranges)]: patterns.html#ranges
227 [Primitive Types (`char`)]: primitive-types.html#char
228 [Primitive Types (Arrays)]: primitive-types.html#arrays
229 [Primitive Types (Booleans)]: primitive-types.html#booleans
230 [Primitive Types (Tuple Indexing)]: primitive-types.html#tuple-indexing
231 [Primitive Types (Tuples)]: primitive-types.html#tuples
232 [Raw Pointers]: raw-pointers.html
233 [Reference (Byte String Literals)]: ../reference.html#byte-string-literals
234 [Reference (Raw Byte String Literals)]: ../reference.html#raw-byte-string-literals
235 [Reference (Raw String Literals)]: ../reference.html#raw-string-literals
236 [References and Borrowing]: references-and-borrowing.html
237 [Strings]: strings.html
238 [Structs (Update syntax)]: structs.html#update-syntax
239 [Structs]: structs.html
240 [Traits (`where` clause)]: traits.html#where-clause
241 [Traits (Multiple Trait Bounds)]: traits.html#multiple-trait-bounds
242 [Traits]: traits.html
243 [Universal Function Call Syntax]: ufcs.html
244 [Universal Function Call Syntax (Angle-bracket Form)]: ufcs.html#angle-bracket-form
245 [Unsafe]: unsafe.html
246 [Unsized Types (`?Sized`)]: unsized-types.html#sized
247 [Variable Bindings]: variable-bindings.html