]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/tuple-index.rs
Merge branch 'master' into cfg_tmp_dir
[rust.git] / src / test / run-pass / tuple-index.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 struct Point(int, int);
12
13 fn main() {
14     let mut x = Point(3, 2);
15     assert_eq!(x.0, 3);
16     assert_eq!(x.1, 2);
17     x.0 += 5;
18     assert_eq!(x.0, 8);
19     {
20         let ry = &mut x.1;
21         *ry -= 2;
22         x.0 += 3;
23         assert_eq!(x.0, 11);
24     }
25     assert_eq!(x.1, 0);
26
27     let mut x = (3i, 2i);
28     assert_eq!(x.0, 3);
29     assert_eq!(x.1, 2);
30     x.0 += 5;
31     assert_eq!(x.0, 8);
32     {
33         let ry = &mut x.1;
34         *ry -= 2;
35         x.0 += 3;
36         assert_eq!(x.0, 11);
37     }
38     assert_eq!(x.1, 0);
39
40 }