5
5
>   ;  ;   ;  ; ` ( ` ` ) ` \
6
6
>   ;  ; | ` ( ` ( [ _ Type_ ] ` , ` )<sup >+</sup > [ _ Type_ ] <sup >?</sup > ` ) `
7
7
8
- The * tuple type* is a structural type[ ^ 1 ] for heterogeneous lists of other
9
- types. Each entry in the list is an * element* [ ^ 2 ] of the tuple. The position of
10
- the element makes it the * nth element* using zero (` 0 ` ) as the initial index.
8
+ The * tuple type* is a structural type[ ^ 1 ] for heterogeneous lists of other types.
9
+ Each entry in the list is an * element* [ ^ 2 ] of the tuple.
10
+ The position of the element makes it the * nth element* using zero (` 0 ` ) as the initial index.
11
11
12
- The number of elements determines the arity of the tuple. A tuple with ` n `
13
- elements is called an ` n-ary tuple ` . For example, a tuple with 2 elements is a
14
- 2-ary tuple.
12
+ The number of elements determines the arity of the tuple.
13
+ A tuple with ` n ` elements is called an ` n-ary tuple ` .
14
+ For example, a tuple with 2 elements is a 2-ary tuple.
15
15
16
- For convenience and historical reasons, the tuple type with no elements (` () ` )
17
- is often called * unit* or * the unit type* . It's one value is also called * unit*
18
- or * the unit value* .
16
+ For convenience and historical reasons, the tuple type with no elements (` () ` ) is often called * unit* or * the unit type* .
17
+ It's one value is also called * unit* or * the unit value* .
19
18
20
- Tuple types are written by listing the types of their elements in a
21
- parenthesized, comma-separated list. 1-ary tuples require a comma after their
22
- element type to be disambiguated with a [ parenthesized type] .
19
+ Tuple types are written by listing the types of their elements in a parenthesized, comma-separated list.
20
+ 1-ary tuples require a comma after their element type to be disambiguated with a [ parenthesized type] .
23
21
24
22
Some examples of tuple types:
25
23
@@ -29,16 +27,14 @@ Some examples of tuple types:
29
27
* ` (i32, String) ` (different type from the previous example)
30
28
* ` (i32, f64, Vec<String>, Option<bool>) `
31
29
32
- Values of this type are constructed using a [ tuple expression] . Furthermore,
33
- various expressions will produce the unit value if there is no other meaningful
34
- value for it to evaluate to. Tuple elements can be accessed by either a [ tuple
35
- index expression] or [ pattern matching] .
30
+ Values of this type are constructed using a [ tuple expression] .
31
+ Furthermore, various expressions will produce the unit value if there is no other meaningful value for it to evaluate to.
32
+ Tuple elements can be accessed by either a [ tuple index expression] or [ pattern matching] .
36
33
37
- [ ^ 1 ] : Structural types are always equivalent if their internal types are
38
- equivalent. For a nominal version of tuples, see [ tuple structs] .
34
+ [ ^ 1 ] : Structural types are always equivalent if their internal types are equivalent.
35
+ For a nominal version of tuples, see [ tuple structs] .
39
36
40
- [ ^ 2 ] : Element is equivalent to field, except numerical indexes instead of
41
- identifiers
37
+ [ ^ 2 ] : Element is equivalent to field, except numerical indexes instead of identifiers
42
38
43
39
[ _Type_ ] : ../types.md#type-expressions
44
40
[ parenthesized type ] : ../types.md#parenthesized-types
0 commit comments