1 // run-pass
2
main()3 fn main() {
4 let (mut a, mut b);
5 (a, b) = (0, 1);
6 assert_eq!((a, b), (0, 1));
7 (b, a) = (a, b);
8 assert_eq!((a, b), (1, 0));
9 (a, .., b) = (1, 2);
10 assert_eq!((a, b), (1, 2));
11 (.., a) = (1, 2);
12 assert_eq!((a, b), (2, 2));
13 (..) = (3, 4);
14 assert_eq!((a, b), (2, 2));
15 (b, ..) = (5, 6, 7);
16 assert_eq!(b, 5);
17 (a, _) = (8, 9);
18 assert_eq!(a, 8);
19
20 // Test for a non-Copy type (String):
21 let (mut c, mut d);
22 (c, d) = ("c".to_owned(), "d".to_owned());
23 assert_eq!(c, "c");
24 assert_eq!(d, "d");
25 (d, c) = (c, d);
26 assert_eq!(c, "d");
27 assert_eq!(d, "c");
28
29 // Test nesting/parentheses:
30 ((a, b)) = (0, 1);
31 assert_eq!((a, b), (0, 1));
32 (((a, b)), (c)) = ((2, 3), d);
33 assert_eq!((a, b), (2, 3));
34 assert_eq!(c, "c");
35 ((a, .., b), .., (..)) = ((4, 5), ());
36 assert_eq!((a, b), (4, 5));
37 }
38