Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
Static items StaticItem -> ItemSafety?[^extern-safety] `static` `mut`? IDENTIFIER `:` Type ( `=` Expression )? `;` [^extern-safety]: The safe and unsafe function qualifiers are only allowed semantically within extern blocks. A static item i...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~3 min read
Constant items ConstantItem -> `const` ( IDENTIFIER | `_` ) `:` Type ( `=` Expression )? `;` A constant item is an optionally named constant value which is not associated with a specific memory location in the program. Constants are essenti...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~2 min read
Unions Union -> `union` IDENTIFIER GenericParams? WhereClause? `{` StructFields? `}` A union declaration uses the same syntax as a struct declaration, except with union in place of struct. A union declaration defines the given name in the t...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~4 min read
Enumerations Enumeration -> `enum` IDENTIFIER GenericParams? WhereClause? `{` EnumVariants? `}` EnumVariants -> EnumVariant ( `,` EnumVariant )* `,`? EnumVariant -> OuterAttribute* Visibility? IDENTIFIER ( EnumVariantTuple | EnumVariantStru...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~5 min read
Structs Struct -> StructStruct | TupleStruct StructStruct -> `struct` IDENTIFIER GenericParams? WhereClause? ( `{` StructFields? `}` | `;` ) TupleStruct -> `struct` IDENTIFIER GenericParams? `(` TupleFields? `)` WhereClause? `;` StructField...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~1 min read
Type aliases TypeAlias -> `type` IDENTIFIER GenericParams? ( `:` Bounds )? WhereClause? ( `=` Type WhereClause?)? `;` A type alias defines a new name for an existing type in the type namespace of the module or block where it is located. Typ...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~1 min read
Functions Function -> FunctionQualifiers `fn` IDENTIFIER GenericParams? `(` FunctionParameters? `)` FunctionReturnType? WhereClause? ( BlockExpression | `;` ) FunctionQualifiers -> `const`? `async`?[^async-edition] ItemSafety?[^extern-quali...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~10 min read
Use declarations UseDeclaration -> `use` UseTree `;` UseTree -> (SimplePath? `::`)? `*` | (SimplePath? `::`)? `{` (UseTree ( `,` UseTree )* `,`?)? `}` | SimplePath ( `as` ( IDENTIFIER | `_` ) )? A use declaration creates one or more local n...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~10 min read
Extern crate declarations ExternCrate -> `extern` `crate` CrateRef AsClause? `;` CrateRef -> IDENTIFIER | `self` AsClause -> `as` ( IDENTIFIER | `_` ) An extern crate declaration specifies a dependency on an external crate. The external cra...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~2 min read
Modules Module -> `unsafe`? `mod` IDENTIFIER `;` | `unsafe`? `mod` IDENTIFIER `{` InnerAttribute* Item* `}` A module is a container for zero or more items. A module item is a module, surrounded in braces, named, and prefixed with the keywor...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~3 min read
Items Item -> OuterAttribute* ( VisItem | MacroItem ) VisItem -> Visibility? ( Module | ExternCrate | UseDeclaration | Function | TypeAlias | Struct | Enumeration | Union | ConstantItem | StaticItem | Trait | Implementation | ExternBlock )...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~1 min read
Conditional compilation ConfigurationPredicate -> ConfigurationOption | ConfigurationAll | ConfigurationAny | ConfigurationNot | `true` | `false` ConfigurationOption -> IDENTIFIER ( `=` ( STRING_LITERAL | RAW_STRING_LITERAL ) )? Configurati...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~9 min read
Crates and source files @root Crate -> InnerAttribute* Item* [!NOTE] Although Rust, like any other language, can be implemented by an interpreter as well as a compiler, the only existing implementation is a compiler, and the language has al...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~3 min read
Procedural macros Procedural macros allow creating syntax extensions as execution of a function. Procedural macros come in one of three flavors: • Function-like macros - custom!(...) • Derive macros - #[derive(CustomDerive)] • Attribute mac...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~10 min read
Macros by example MacroRulesDefinition -> `macro_rules` `!` IDENTIFIER MacroRulesDef MacroRulesDef -> `(` MacroRules `)` `;` | `[` MacroRules `]` `;` | `{` MacroRules `}` MacroRules -> MacroRule ( `;` MacroRule )* `;`? MacroRule -> MacroMat...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~18 min read
Macros The functionality and syntax of Rust can be extended with custom definitions called macros. They are given names, and invoked through a consistent syntax: some_extension!(...). There are two ways to define new macros: • Macros by Exa...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~1 min read
Tokens Token -> RESERVED_TOKEN | RAW_IDENTIFIER | CHAR_LITERAL | STRING_LITERAL | RAW_STRING_LITERAL | BYTE_LITERAL | BYTE_STRING_LITERAL | RAW_BYTE_STRING_LITERAL | C_STRING_LITERAL | RAW_C_STRING_LITERAL | FLOAT_LITERAL | INTEGER_LITERAL...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~20 min read
Whitespace WHITESPACE -> U+0009 // Horizontal tab, `'\t'` | U+000A // Line feed, `'\n'` | U+000B // Vertical tab | U+000C // Form feed | U+000D // Carriage return, `'\r'` | U+0020 // Space, `' '` | U+0085 // Next line | U+200E // Left-to-ri...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~1 min read
Comments @root COMMENT -> LINE_COMMENT | INNER_LINE_DOC | OUTER_LINE_DOC | INNER_BLOCK_DOC | OUTER_BLOCK_DOC | BLOCK_COMMENT LINE_COMMENT -> `//` (~[`/` `!` LF] | `//`) ~LF* | `//` EOF | `//` _immediately followed by LF_ BLOCK_COMMENT -> `/...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~2 min read
Identifiers IDENTIFIER_OR_KEYWORD -> ( XID_Start | `_` ) XID_Continue* XID_Start -> <`XID_Start` defined by Unicode> XID_Continue -> <`XID_Continue` defined by Unicode> RAW_IDENTIFIER -> `r#` IDENTIFIER_OR_KEYWORD NON_KEYWORD_IDENTIFIER ->...
doc.rust-lang.org The Rust Reference Book 2024-01-01 ~1 min read
"And even if you could fix all of rustc's soundness holes, or otherwise prevent user code from exploiting them, a soundness bug in any third-party libr..."

Search tips

Type anything to search across articles, videos (including conference talks), podcasts, and research. These operators give you finer control — click an example to try it.

Find pages containing all your words. Pages where the words appear together rank higher.
Quote part of your query to keep those words together as an exact phrase within a larger search.
Wrap the whole query in quotes for a verbatim search that matches text exactly, punctuation and all — perfect for Rust syntax. Needs at least 3 characters.
Limit results to a single site. Works on its own () too. One site: per search.

Use the tabs and filters above the results to narrow by content type, publication year, and sort order.