@@ -2524,10 +2524,10 @@ Note that for a given *unit-like* structure type, this will always be the same v
2524
2524
2525
2525
A structure expression can terminate with the syntax ` .. ` followed by an expression to denote a functional update.
2526
2526
The expression following ` .. ` (the base) must have the same structure type as the new structure type being formed.
2527
- The entire expression denotes the result of allocating a new structure
2527
+ The entire expression denotes the result of constructing a new structure
2528
2528
(with the same type as the base expression)
2529
2529
with the given values for the fields that were explicitly specified
2530
- and the values in the base record for all other fields.
2530
+ and the values in the base expression for all other fields.
2531
2531
2532
2532
~~~~
2533
2533
# struct Point3d { x: int, y: int, z: int }
@@ -2575,15 +2575,15 @@ when not immediately followed by a parenthesized expression-list (the latter is
2575
2575
A field expression denotes a field of a [ structure] ( #structure-types ) .
2576
2576
2577
2577
~~~~ {.ignore .field}
2578
- myrecord .myfield;
2578
+ mystruct .myfield;
2579
2579
foo().x;
2580
2580
(Struct {a: 10, b: 20}).a;
2581
2581
~~~~
2582
2582
2583
- A field access on a record is an [ lvalue] ( #lvalues-rvalues-and-temporaries ) referring to the value of that field.
2584
- When the field is mutable , it can be [ assigned] ( #assignment-expressions ) to.
2583
+ A field access is an [ lvalue] ( #lvalues-rvalues-and-temporaries ) referring to the value of that field.
2584
+ When the type providing the field inherits mutabilty , it can be [ assigned] ( #assignment-expressions ) to.
2585
2585
2586
- When the type of the expression to the left of the dot is a pointer to a record or structure ,
2586
+ Also, if the type of the expression to the left of the dot is a pointer,
2587
2587
it is automatically dereferenced to make the field access possible.
2588
2588
2589
2589
### Vector expressions
@@ -3038,7 +3038,7 @@ match_pat : pat [ '|' pat ] * [ "if" expr ] ? ;
3038
3038
3039
3039
A ` match ` expression branches on a * pattern* . The exact form of matching that
3040
3040
occurs depends on the pattern. Patterns consist of some combination of
3041
- literals, destructured vectors or enum constructors, structures, records and
3041
+ literals, destructured vectors or enum constructors, structures and
3042
3042
tuples, variable binding specifications, wildcards (` .. ` ), and placeholders
3043
3043
(` _ ` ). A ` match ` expression has a * head expression* , which is the value to
3044
3044
compare to the patterns. The type of the patterns must equal the type of the
@@ -3315,17 +3315,16 @@ such as `&str` or `String`.
3315
3315
3316
3316
### Tuple types
3317
3317
3318
- The tuple type-constructor forms a new heterogeneous product of values similar
3319
- to the record type-constructor. The differences are as follows:
3320
-
3321
- * tuple elements cannot be mutable, unlike record fields
3322
- * tuple elements are not named and can be accessed only by pattern-matching
3318
+ A tuple * type* is a heterogeneous product of other types, called the * elements*
3319
+ of the tuple. It has no nominal name and is instead structurally typed.
3323
3320
3324
3321
Tuple types and values are denoted by listing the types or values of their
3325
3322
elements, respectively, in a parenthesized, comma-separated
3326
3323
list.
3327
3324
3328
- The members of a tuple are laid out in memory contiguously, like a record, in
3325
+ Because tuple elements don't have a name, they can only be accessed by pattern-matching.
3326
+
3327
+ The members of a tuple are laid out in memory contiguously, in
3329
3328
order specified by the tuple type.
3330
3329
3331
3330
An example of a tuple type and its use:
@@ -3377,12 +3376,13 @@ of the type.[^structtype]
3377
3376
3378
3377
New instances of a ` struct ` can be constructed with a [ struct expression] ( #structure-expressions ) .
3379
3378
3380
- The memory order of fields in a ` struct ` is given by the item defining it.
3381
- Fields may be given in any order in a corresponding struct * expression* ;
3382
- the resulting ` struct ` value will always be laid out in memory in the order specified by the corresponding * item* .
3379
+ The memory layout of a ` struct ` is undefined by default to allow for compiler optimziations like
3380
+ field reordering, but it can be fixed with the ` #[repr(...)] ` attribute.
3381
+ In either case, fields may be given in any order in a corresponding struct * expression* ;
3382
+ the resulting ` struct ` value will always have the same memory layout.
3383
3383
3384
3384
The fields of a ` struct ` may be qualified by [ visibility modifiers] ( #re-exporting-and-visibility ) ,
3385
- to restrict access to implementation-private data in a structure.
3385
+ to allow access to data in a structure outside a module .
3386
3386
3387
3387
A _ tuple struct_ type is just like a structure type, except that the fields are anonymous.
3388
3388
@@ -3933,7 +3933,7 @@ The runtime provides C and Rust code to assist with various built-in types,
3933
3933
such as vectors, strings, and the low level communication system (ports,
3934
3934
channels, tasks).
3935
3935
3936
- Support for other built-in types such as simple types, tuples, records, and
3936
+ Support for other built-in types such as simple types, tuples and
3937
3937
enums is open-coded by the Rust compiler.
3938
3938
3939
3939
### Task scheduling and communication
0 commit comments