Skip to content

Latest commit

 

History

History
116 lines (103 loc) · 3.87 KB

items.md

File metadata and controls

116 lines (103 loc) · 3.87 KB

Items

r[items]

r[items.syntax]

Syntax:
Item:
   OuterAttribute*
      VisItem
   | MacroItem

VisItem:
   Visibility?
   (
         Module
      | ExternCrate
      | UseDeclaration
      | Function
      | TypeAlias
      | Struct
      | Enumeration
      | Union
      | ConstantItem
      | StaticItem
      | Trait
      | Implementation
      | ExternBlock
   )

MacroItem:
      MacroInvocationSemi
   | MacroRulesDefinition

r[items.intro] 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.

r[items.static-def] Items are entirely determined at compile-time, generally remain fixed during execution, and may reside in read-only memory.

r[items.kinds] There are several kinds of items:

r[items.locations] Items may be declared in the root of the crate, a module, or a block expression.

r[items.associated-locations] A subset of items, called associated items, may be declared in traits and implementations.

r[items.extern-locations] A subset of items, called external items, may be declared in extern blocks.

r[items.decl-order] Items may be defined in any order, with the exception of macro_rules which has its own scoping behavior.

r[items.name-resolution] 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.