2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2015-03-22 20:13:15 +00:00
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
struct Foo(isize, isize);
|
2014-08-10 03:54:33 +00:00
|
|
|
|
|
|
|
fn main() {
|
2015-01-25 21:05:03 +00:00
|
|
|
let x = (1, 2);
|
2014-08-10 03:54:33 +00:00
|
|
|
let a = &x.0;
|
|
|
|
let b = &x.0;
|
|
|
|
assert_eq!(*a, 1);
|
|
|
|
assert_eq!(*b, 1);
|
|
|
|
|
2015-01-25 21:05:03 +00:00
|
|
|
let mut x = (1, 2);
|
2014-08-10 03:54:33 +00:00
|
|
|
{
|
|
|
|
let a = &x.0;
|
|
|
|
let b = &mut x.1;
|
|
|
|
*b = 5;
|
|
|
|
assert_eq!(*a, 1);
|
|
|
|
}
|
|
|
|
assert_eq!(x.0, 1);
|
|
|
|
assert_eq!(x.1, 5);
|
|
|
|
|
|
|
|
|
2015-01-25 21:05:03 +00:00
|
|
|
let x = Foo(1, 2);
|
2014-08-10 03:54:33 +00:00
|
|
|
let a = &x.0;
|
|
|
|
let b = &x.0;
|
|
|
|
assert_eq!(*a, 1);
|
|
|
|
assert_eq!(*b, 1);
|
|
|
|
|
2015-01-25 21:05:03 +00:00
|
|
|
let mut x = Foo(1, 2);
|
2014-08-10 03:54:33 +00:00
|
|
|
{
|
|
|
|
let a = &x.0;
|
|
|
|
let b = &mut x.1;
|
|
|
|
*b = 5;
|
|
|
|
assert_eq!(*a, 1);
|
|
|
|
}
|
|
|
|
assert_eq!(x.0, 1);
|
|
|
|
assert_eq!(x.1, 5);
|
|
|
|
}
|