@@ -617,8 +617,8 @@ each of which may have some number of [attributes](#attributes) attached to it.
617
617
## Items
618
618
619
619
~~~~~~~~ {.ebnf .gram}
620
- item : mod_item | fn_item | type_item | enum_item
621
- | const_item | trait_item | impl_item | foreign_mod_item ;
620
+ item : mod_item | fn_item | type_item | struct_item | enum_item
621
+ | static_item | trait_item | impl_item | foreign_mod_item ;
622
622
~~~~~~~~
623
623
624
624
An _ item_ is a component of a crate; some module items can be defined in crate
@@ -627,7 +627,7 @@ crate by a nested set of [modules](#modules). Every crate has a single
627
627
"outermost" anonymous module; all further items within the crate have
628
628
[ paths] ( #paths ) within the module tree of the crate.
629
629
630
- Items are entirely determined at compile-time, remain constant during
630
+ Items are entirely determined at compile-time, generally remain fixed during
631
631
execution, and may reside in read-only memory.
632
632
633
633
There are several kinds of item:
@@ -637,7 +637,7 @@ There are several kinds of item:
637
637
* [ type definitions] ( #type-definitions )
638
638
* [ structures] ( #structures )
639
639
* [ enumerations] ( #enumerations )
640
- * [ constants ] ( #constants )
640
+ * [ static items ] ( #static-items )
641
641
* [ traits] ( #traits )
642
642
* [ implementations] ( #implementations )
643
643
@@ -1091,21 +1091,23 @@ a = Cat{ name: ~"Spotty", weight: 2.7 };
1091
1091
In this example, ` Cat ` is a _ struct-like enum variant_ ,
1092
1092
whereas ` Dog ` is simply called an enum variant.
1093
1093
1094
- ### Constants
1094
+ ### Static items
1095
1095
1096
1096
~~~~~~~~ {.ebnf .gram}
1097
- const_item : "const " ident ':' type '=' expr ';' ;
1097
+ static_item : "static " ident ':' type '=' expr ';' ;
1098
1098
~~~~~~~~
1099
1099
1100
- A * constant* is a named value stored in read-only memory in a crate.
1101
- The value bound to a constant is evaluated at compile time.
1102
- Constants are declared with the ` static ` keyword.
1103
- A constant item must have an expression giving its definition.
1104
- The definition expression of a constant is limited to expression forms that can be evaluated at compile time.
1100
+ A * static item* is a named _ constant value_ stored in the global data section of a crate.
1101
+ Immutable static items are stored in the read-only data section.
1102
+ The constant value bound to a static item is, like all constant values, evaluated at compile time.
1103
+ Static items have the ` static ` lifetime, which outlives all other lifetimes in a Rust program.
1104
+ Static items are declared with the ` static ` keyword.
1105
+ A static item must have a _ constant expression_ giving its definition.
1105
1106
1106
- Constants must be explicitly typed. The type may be ``` bool ``` , ``` char ``` , a number, or a type derived from those primitive types.
1107
- The derived types are borrowed pointers, static arrays, tuples, and structs.
1108
- Borrowed pointers must be have the ` 'static ` lifetime.
1107
+ Static items must be explicitly typed.
1108
+ The type may be ``` bool ``` , ``` char ``` , a number, or a type derived from those primitive types.
1109
+ The derived types are borrowed pointers with the ` 'static ` lifetime,
1110
+ fixed-size arrays, tuples, and structs.
1109
1111
1110
1112
~~~~
1111
1113
static bit1: uint = 1 << 0;
@@ -1456,7 +1458,7 @@ The declared names may denote new slots or new items.
1456
1458
1457
1459
An _ item declaration statement_ has a syntactic form identical to an
1458
1460
[ item] ( #items ) declaration within a module. Declaring an item -- a function,
1459
- enumeration, type, constant , trait, implementation or module -- locally
1461
+ enumeration, structure, type, static , trait, implementation or module -- locally
1460
1462
within a statement block is simply a way of restricting its scope to a narrow
1461
1463
region containing all of its uses; it is otherwise identical in meaning to
1462
1464
declaring the item outside the statement block.
0 commit comments