| # Items |
| |
| > **<sup>Syntax:<sup>**\ |
| > _Item_:\ |
| > [_OuterAttribute_]<sup>\*</sup>\ |
| > _VisItem_\ |
| > | _MacroItem_ |
| > |
| > _VisItem_:\ |
| > [_Visibility_]<sup>?</sup>\ |
| > (\ |
| > [_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` declarations] |
| * [`use` declarations] |
| * [function definitions] |
| * [type definitions] |
| * [struct definitions] |
| * [enumeration definitions] |
| * [union definitions] |
| * [constant items] |
| * [static items] |
| * [trait definitions] |
| * [implementations] |
| * [`extern` blocks] |
| |
| Some items form an implicit scope for the declaration of sub-items. In other |
| words, within a function or module, declarations of items can (in many cases) |
| be mixed with the statements, control blocks, and similar artifacts that |
| otherwise compose the item body. The meaning of these scoped items is the same |
| as if the item was declared outside the scope — it is still a static item |
| — except that the item's *path name* within the module namespace is |
| qualified by the name of the enclosing item, or is private to the enclosing |
| item (in the case of functions). The grammar specifies the exact locations in |
| which sub-item declarations may appear. |
| |
| [_ConstantItem_]: items/constant-items.md |
| [_Enumeration_]: items/enumerations.md |
| [_ExternBlock_]: items/external-blocks.md |
| [_ExternCrate_]: items/extern-crates.md |
| [_Function_]: items/functions.md |
| [_Implementation_]: items/implementations.md |
| [_MacroInvocationSemi_]: macros.md#macro-invocation |
| [_MacroRulesDefinition_]: macros-by-example.md |
| [_Module_]: items/modules.md |
| [_OuterAttribute_]: attributes.md |
| [_StaticItem_]: items/static-items.md |
| [_Struct_]: items/structs.md |
| [_Trait_]: items/traits.md |
| [_TypeAlias_]: items/type-aliases.md |
| [_Union_]: items/unions.md |
| [_UseDeclaration_]: items/use-declarations.md |
| [_Visibility_]: visibility-and-privacy.md |
| [`extern crate` declarations]: items/extern-crates.md |
| [`extern` blocks]: items/external-blocks.md |
| [`use` declarations]: items/use-declarations.md |
| [constant items]: items/constant-items.md |
| [enumeration definitions]: items/enumerations.md |
| [function definitions]: items/functions.md |
| [implementations]: items/implementations.md |
| [modules]: items/modules.md |
| [paths]: paths.md |
| [static items]: items/static-items.md |
| [struct definitions]: items/structs.md |
| [trait definitions]: items/traits.md |
| [type definitions]: items/type-aliases.md |
| [union definitions]: items/unions.md |