Items
Syntax:
Item:
OuterAttribute*
VisItem
| MacroItemVisItem:
Visibility?
(
Module
| ExternCrate
| UseDeclaration
| Function
| TypeAlias
| Struct
| Enumeration
| Union
| ConstantItem
| StaticItem
| Trait
| Implementation
| ExternBlock
)MacroItem:
MacroInvocationSemi
| MacroRulesDefinition
An item is a component of a crate. Items are organized within a crate by a nested set of modules. Every crate has a single “outermost” anonymous module; all further items within the crate have paths within the module tree of the crate.
Items are entirely determined at compile-time, generally remain fixed during execution, and may reside in read-only memory.
There are several kinds of items:
- modules
extern crate
declarationsuse
declarations- function definitions
- type definitions
- struct definitions
- enumeration definitions
- union definitions
- constant items
- static items
- trait definitions
- implementations
extern
blocks
Items may be declared in the root of the crate, a module, or a block expression.
A subset of items, called associated items, may be declared in traits and implementations.
A subset of items, called external items, may be declared in extern
blocks.
Items may be defined in any order, with the exception of macro_rules
which has its own scoping behavior.
Name resolution of item names allows items to be defined before or after where the item is referred to in the module or block.
See item scopes for information on the scoping rules of items.