Skip to content

Commit 3d31a6b

Browse files
committed
Remove several references to resources; add section for Constants.
1 parent cad6733 commit 3d31a6b

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

doc/rust.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ There are several kinds of item:
706706
* [functions](#functions)
707707
* [type definitions](#type-definitions)
708708
* [enumerations](#enumerations)
709-
* [resources](#resources)
709+
* [constants](#constants)
710710
* [traits](#traits)
711711
* [implementations](#implementations)
712712

@@ -1151,6 +1151,18 @@ enum list<T> {
11511151
let a: list<int> = cons(7, @cons(13, @nil));
11521152
~~~~
11531153

1154+
### Constants
1155+
1156+
~~~~~~~~ {.ebnf .gram}
1157+
const_item : "const" ident ':' type '=' expr ';' ;
1158+
~~~~~~~~
1159+
1160+
A Constant is a named value stored in read-only memory in a crate.
1161+
The value bound to a constant is evaluated at compile time.
1162+
Constants are declared with the `const` keyword.
1163+
A constant item must have an expression giving its definition.
1164+
The definition expression of a constant is limited to expression forms that can be evaluated at compile time.
1165+
11541166
### Traits
11551167

11561168
A _trait item_ describes a set of method types. [_implementation
@@ -1425,7 +1437,7 @@ statement block. The declared name may denote a new slot or a new item.
14251437

14261438
An _item declaration statement_ has a syntactic form identical to an
14271439
[item](#items) declaration within a module. Declaring an item -- a function,
1428-
enumeration, type, resource, trait, implementation or module -- locally
1440+
enumeration, type, constant, trait, implementation or module -- locally
14291441
within a statement block is simply a way of restricting its scope to a narrow
14301442
region containing all of its uses; it is otherwise identical in meaning to
14311443
declaring the item outside the statement block.
@@ -1629,8 +1641,7 @@ operators, before the expression they apply to.
16291641
`-`
16301642
: Negation. May only be applied to numeric types.
16311643
`*`
1632-
: Dereference. When applied to a [box](#box-types) or
1633-
[resource](#resources) type, it accesses the inner value. For
1644+
: Dereference. When applied to a [pointer](#pointer-types) it denotes the pointed-to location. For
16341645
mutable boxes, the resulting [lvalue](#lvalues-rvalues-and-temporaries) can be assigned to. For
16351646
[enums](#enumerated-types) that have only a single variant,
16361647
containing a single parameter, the dereference operator accesses
@@ -2185,7 +2196,7 @@ fail_expr : "fail" expr ? ;
21852196

21862197
Evaluating a `fail` expression causes a task to enter the *failing* state. In
21872198
the *failing* state, a task unwinds its stack, destroying all frames and
2188-
freeing all resources until it reaches its entry frame, at which point it
2199+
running all destructors until it reaches its entry frame, at which point it
21892200
halts execution in the *dead* state.
21902201

21912202

0 commit comments

Comments
 (0)