mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Rollup merge of #26787 - tshepang:tuple-usage, r=steveklabnik
This commit is contained in:
commit
ec37d456aa
@ -3328,10 +3328,13 @@ An example of a tuple type and its use:
|
||||
|
||||
```
|
||||
type Pair<'a> = (i32, &'a str);
|
||||
let p: Pair<'static> = (10, "hello");
|
||||
let p: Pair<'static> = (10, "ten");
|
||||
let (a, b) = p;
|
||||
assert!(b != "world");
|
||||
assert!(p.0 == 10);
|
||||
|
||||
assert_eq!(a, 10);
|
||||
assert_eq!(b, "ten");
|
||||
assert_eq!(p.0, 10);
|
||||
assert_eq!(p.1, "ten");
|
||||
```
|
||||
|
||||
For historical reasons and convenience, the tuple type with no elements (`()`)
|
||||
|
Loading…
Reference in New Issue
Block a user