diff --git a/src/expressions/tuple-expr.md b/src/expressions/tuple-expr.md index 0236d0553..af330ce05 100644 --- a/src/expressions/tuple-expr.md +++ b/src/expressions/tuple-expr.md @@ -10,8 +10,7 @@ >    ( [_Expression_] `,` )+ [_Expression_]? Tuples are written by enclosing zero or more comma-separated expressions in -parentheses. They are used to create [tuple-typed](../types/tuple.md) -values. +parentheses. They are used to create [tuple-typed] values. ```rust (0.0, 4.5); @@ -19,8 +18,21 @@ values. (); ``` -You can disambiguate a single-element tuple from a value in parentheses with a -comma: +The inner expressions are evaluated from left to right. + +```rust +#// Using vec instead of array to avoid references +#// since there is no stable owned array iterator +#// at the time this example was written. +let mut one_two = vec![1, 2].into_iter(); +assert_eq!( + (1, 2), + (one_two.next().unwrap(), one_two.next().unwrap()) +); +``` + +Single-element tuples are disambiguated from a [parenthetical expression] with a +comma before the closing parethesis: ```rust (0,); // single-element tuple @@ -54,8 +66,10 @@ let unit_x = Point(1.0, 0.0); assert_eq!(unit_x.0, 1.0); ``` -[Inner attributes]: ../attributes.md -[TUPLE_INDEX]: ../tokens.md#tuple-index [_Expression_]: ../expressions.md [_InnerAttribute_]: ../attributes.md [attributes on block expressions]: block-expr.md#attributes-on-block-expressions +[Inner attributes]: ../attributes.md +[parenthetical expression]: grouped-expr.md +[tuple-typed]: ../types/tuple.md +[TUPLE_INDEX]: ../tokens.md#tuple-index \ No newline at end of file