@@ -674,7 +674,7 @@ There are several kinds of item:
674
674
* [ modules] ( #modules )
675
675
* [ functions] ( #functions )
676
676
* [ type definitions] ( grammar.html#type-definitions )
677
- * [ structures ] ( #structures )
677
+ * [ structs ] ( #structs )
678
678
* [ enumerations] ( #enumerations )
679
679
* [ constant items] ( #constant-items )
680
680
* [ static items] ( #static-items )
@@ -900,9 +900,10 @@ fn main() {}
900
900
901
901
### Functions
902
902
903
- A _ function item_ defines a sequence of [ statements] ( #statements ) and an
904
- optional final [ expression] ( #expressions ) , along with a name and a set of
905
- parameters. Functions are declared with the keyword ` fn ` . Functions declare a
903
+ A _ function item_ defines a sequence of [ statements] ( #statements ) and a
904
+ final [ expression] ( #expressions ) , along with a name and a set of
905
+ parameters. Other than a name, all these are optional.
906
+ Functions are declared with the keyword ` fn ` . Functions may declare a
906
907
set of * input* [ * variables* ] ( #variables ) as parameters, through which the caller
907
908
passes arguments into the function, and the * output* [ * type* ] ( #types )
908
909
of the value the function will return to its caller on completion.
@@ -921,7 +922,7 @@ An example of a function:
921
922
922
923
```
923
924
fn add(x: i32, y: i32) -> i32 {
924
- return x + y;
925
+ x + y
925
926
}
926
927
```
927
928
@@ -1155,7 +1156,7 @@ type Point = (u8, u8);
1155
1156
let p: Point = (41, 68);
1156
1157
```
1157
1158
1158
- ### Structures
1159
+ ### Structs
1159
1160
1160
1161
A _ structure_ is a nominal [ structure type] ( #structure-types ) defined with the
1161
1162
keyword ` struct ` .
@@ -2619,21 +2620,21 @@ comma:
2619
2620
### Structure expressions
2620
2621
2621
2622
There are several forms of structure expressions. A _ structure expression_
2622
- consists of the [ path] ( #paths ) of a [ structure item] ( #structures ) , followed by
2623
+ consists of the [ path] ( #paths ) of a [ structure item] ( #structs ) , followed by
2623
2624
a brace-enclosed list of one or more comma-separated name-value pairs,
2624
2625
providing the field values of a new instance of the structure. A field name
2625
2626
can be any identifier, and is separated from its value expression by a colon.
2626
2627
The location denoted by a structure field is mutable if and only if the
2627
2628
enclosing structure is mutable.
2628
2629
2629
2630
A _ tuple structure expression_ consists of the [ path] ( #paths ) of a [ structure
2630
- item] ( #structures ) , followed by a parenthesized list of one or more
2631
+ item] ( #structs ) , followed by a parenthesized list of one or more
2631
2632
comma-separated expressions (in other words, the path of a structure item
2632
2633
followed by a tuple expression). The structure item must be a tuple structure
2633
2634
item.
2634
2635
2635
2636
A _ unit-like structure expression_ consists only of the [ path] ( #paths ) of a
2636
- [ structure item] ( #structures ) .
2637
+ [ structure item] ( #structs ) .
2637
2638
2638
2639
The following are examples of structure expressions:
2639
2640
@@ -3150,7 +3151,7 @@ if` condition is evaluated. If all `if` and `else if` conditions evaluate to
3150
3151
3151
3152
A ` match ` expression branches on a * pattern* . The exact form of matching that
3152
3153
occurs depends on the pattern. Patterns consist of some combination of
3153
- literals, destructured arrays or enum constructors, structures and tuples,
3154
+ literals, destructured arrays or enum constructors, structs and tuples,
3154
3155
variable binding specifications, wildcards (` .. ` ), and placeholders (` _ ` ). A
3155
3156
` match ` expression has a * head expression* , which is the value to compare to
3156
3157
the patterns. The type of the patterns must equal the type of the head
@@ -3474,7 +3475,7 @@ named reference to an [`enum` item](#enumerations).
3474
3475
### Recursive types
3475
3476
3476
3477
Nominal types &mdash ; [ enumerations] ( #enumerated-types ) and
3477
- [ structures ] ( #structure-types ) &mdash ; may be recursive. That is, each ` enum `
3478
+ [ structs ] ( #structure-types ) &mdash ; may be recursive. That is, each ` enum `
3478
3479
constructor or ` struct ` field may refer, directly or indirectly, to the
3479
3480
enclosing ` enum ` or ` struct ` type itself. Such recursion has restrictions:
3480
3481
@@ -3502,7 +3503,7 @@ let a: List<i32> = List::Cons(7, Box::new(List::Cons(13, Box::new(List::Nil))));
3502
3503
### Pointer types
3503
3504
3504
3505
All pointers in Rust are explicit first-class values. They can be copied,
3505
- stored into data structures , and returned from functions. There are two
3506
+ stored into data structs , and returned from functions. There are two
3506
3507
varieties of pointer in Rust:
3507
3508
3508
3509
* References (` & ` )
@@ -3902,7 +3903,7 @@ references to boxes are dropped.
3902
3903
### Variables
3903
3904
3904
3905
A _ variable_ is a component of a stack frame, either a named function parameter,
3905
- an anonymous [ temporary] ( #lvalues, -rvalues-and-temporaries ) , or a named local
3906
+ an anonymous [ temporary] ( #lvalues-rvalues-and-temporaries ) , or a named local
3906
3907
variable.
3907
3908
3908
3909
A _ local variable_ (or * stack-local* allocation) holds a value directly,
@@ -4041,10 +4042,6 @@ In general, `--crate-type=bin` or `--crate-type=lib` should be sufficient for
4041
4042
all compilation needs, and the other options are just available if more
4042
4043
fine-grained control is desired over the output format of a Rust crate.
4043
4044
4044
- # Appendix: Rationales and design trade-offs
4045
-
4046
- * TODO* .
4047
-
4048
4045
# Appendix: Influences
4049
4046
4050
4047
Rust is not a particularly original language, with design elements coming from
0 commit comments