doc.rust-lang.org
Operator expressions OperatorExpression -> BorrowExpression | DereferenceExpression | TryPropagationExpression | NegationExpression | ArithmeticOrLogicalExpression | ComparisonExpression | LazyBooleanExpression | TypeCastExpression | Assign...
The Rust Reference
Book
2024-01-01
~28 min read
doc.rust-lang.org
Block expressions BlockExpression -> `{` InnerAttribute* Statements? `}` BlockExpressionNoInnerAttributes -> `{` Statements? `}` Statements -> Statement+ | Statement+ ExpressionWithoutBlock | ExpressionWithoutBlock A block expression, or bl...
The Rust Reference
Book
2024-01-01
~7 min read
doc.rust-lang.org
Path expressions PathExpression -> PathInExpression | QualifiedPathInExpression A path used as an expression context denotes either a local variable or an item. Path expressions that resolve to local or static variables are place expression...
The Rust Reference
Book
2024-01-01
~1 min read
doc.rust-lang.org
Literal expressions LiteralExpression -> CHAR_LITERAL | STRING_LITERAL | RAW_STRING_LITERAL | BYTE_LITERAL | BYTE_STRING_LITERAL | RAW_BYTE_STRING_LITERAL | C_STRING_LITERAL | RAW_C_STRING_LITERAL | INTEGER_LITERAL | FLOAT_LITERAL | `true`...
The Rust Reference
Book
2024-01-01
~12 min read
doc.rust-lang.org
Expressions Expression -> ExpressionWithoutBlock | ExpressionWithBlock ExpressionWithoutBlock -> OuterAttribute* ExpressionWithoutBlockNoAttrs ExpressionWithoutBlockNoAttrs -> LiteralExpression | PathExpression | OperatorExpression | Groupe...
The Rust Reference
Book
2024-01-01
~9 min read
doc.rust-lang.org
Statements Statement -> `;` | Item | LetStatement | ExpressionStatement | OuterAttribute* MacroInvocationSemi A statement is a component of a block, which is in turn a component of an outer expression or function. Rust has two kinds of stat...
The Rust Reference
Book
2024-01-01
~3 min read
doc.rust-lang.org
Statements and expressions Rust is primarily an expression language. This means that most forms of value-producing or effect-causing evaluation are directed by the uniform syntax category of expressions. Each kind of expression can typicall...
The Rust Reference
Book
2024-01-01
~1 min read
doc.rust-lang.org
Debugger attributes The following attributes are used for enhancing the debugging experience when using third-party debuggers like GDB or WinDbg. The debugger_visualizer attribute The debugger_visualizer attribute can be used to embed a deb...
The Rust Reference
Book
2024-01-01
~3 min read
doc.rust-lang.org
Type system attributes The following attributes are used for changing how a type can be used. The non_exhaustive attribute The non_exhaustive attribute indicates that a type or variant may have more fields or variants added in the future. I...
The Rust Reference
Book
2024-01-01
~4 min read
doc.rust-lang.org
Limits The following attributes affect compile-time limits. The recursion_limit attribute The recursion_limit attribute may be applied at the crate level to set the maximum depth for potentially infinitely-recursive compile-time operations...
The Rust Reference
Book
2024-01-01
~1 min read
doc.rust-lang.org
Code generation attributes The following attributes are used for controlling code generation. The inline attribute The inline attribute suggests whether a copy of the attributed function's code should be placed in the caller rather than gen...
The Rust Reference
Book
2024-01-01
~22 min read
doc.rust-lang.org
Diagnostic attributes The following attributes are used for controlling or generating diagnostic messages during compilation. Lint check attributes A lint check names a potentially undesirable coding pattern, such as unreachable code or omi...
The Rust Reference
Book
2024-01-01
~17 min read
doc.rust-lang.org
Derive The derive [attribute][attributes] invokes one or more derive macros, allowing new items to be automatically generated for data structures. You can create derive macros with procedural macros. [!EXAMPLE] The [PartialEq][macro@Partial...
The Rust Reference
Book
2024-01-01
~1 min read
doc.rust-lang.org
Testing attributes The following attributes are used for specifying functions for performing tests. Compiling a crate in "test" mode enables building the test functions along with a test harness for executing the tests. Enabling the test mo...
The Rust Reference
Book
2024-01-01
~3 min read
doc.rust-lang.org
Attributes InnerAttribute -> `#` `!` `[` Attr `]` OuterAttribute -> `#` `[` Attr `]` Attr -> SimplePath AttrInput? | `unsafe` `(` SimplePath AttrInput? `)` AttrInput -> DelimTokenTree | `=` Expression An attribute is a general, free-form me...
The Rust Reference
Book
2024-01-01
~7 min read
doc.rust-lang.org
Associated items AssociatedItem -> OuterAttribute* ( MacroInvocationSemi | ( Visibility? ( TypeAlias | ConstantItem | Function ) ) ) Associated Items are the items declared in traits or defined in implementations. They are called this becau...
The Rust Reference
Book
2024-01-01
~10 min read
doc.rust-lang.org
Generic parameters GenericParams -> `<` ( GenericParam (`,` GenericParam)* `,`? )? `>` GenericParam -> OuterAttribute* ( LifetimeParam | TypeParam | ConstParam ) LifetimeParam -> Lifetime ( `:` LifetimeBounds )? TypeParam -> IDENTIFIER ( `:...
The Rust Reference
Book
2024-01-01
~7 min read
doc.rust-lang.org
External blocks ExternBlock -> `unsafe`?[^unsafe-2024] `extern` Abi? `{` InnerAttribute* ExternalItem* `}` ExternalItem -> OuterAttribute* ( MacroInvocationSemi | Visibility? StaticItem | Visibility? Function ) [^unsafe-2024]: Starting with...
The Rust Reference
Book
2024-01-01
~13 min read
doc.rust-lang.org
Implementations Implementation -> InherentImpl | TraitImpl InherentImpl -> `impl` GenericParams? Type WhereClause? `{` InnerAttribute* AssociatedItem* `}` TraitImpl -> `unsafe`? `impl` GenericParams? `!`? TypePath `for` Type WhereClause? `{...
The Rust Reference
Book
2024-01-01
~6 min read
doc.rust-lang.org
Traits Trait -> `unsafe`? `trait` IDENTIFIER GenericParams? ( `:` Bounds? )? WhereClause? `{` InnerAttribute* AssociatedItem* `}` A trait describes an abstract interface that types can implement. This interface consists of associated items,...
The Rust Reference
Book
2024-01-01
~8 min read