Move /src/test to /tests
This commit is contained in:
parent
ca855e6e42
commit
cf2dff2b1e
27592 changed files with 0 additions and 0 deletions
38
tests/ui/structs-enums/borrow-tuple-fields.rs
Normal file
38
tests/ui/structs-enums/borrow-tuple-fields.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
// run-pass
|
||||
|
||||
struct Foo(isize, isize);
|
||||
|
||||
fn main() {
|
||||
let x = (1, 2);
|
||||
let a = &x.0;
|
||||
let b = &x.0;
|
||||
assert_eq!(*a, 1);
|
||||
assert_eq!(*b, 1);
|
||||
|
||||
let mut x = (1, 2);
|
||||
{
|
||||
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);
|
||||
|
||||
|
||||
let x = Foo(1, 2);
|
||||
let a = &x.0;
|
||||
let b = &x.0;
|
||||
assert_eq!(*a, 1);
|
||||
assert_eq!(*b, 1);
|
||||
|
||||
let mut x = Foo(1, 2);
|
||||
{
|
||||
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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue