summary refs log tree commit diff
path: root/src/test/ui/exterior.rs
blob: 6f2c37926bea65167b0952d2aa3f804df25fa472 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// run-pass

#![allow(dead_code)]


use std::cell::Cell;

#[derive(Copy, Clone)]
struct Point {x: isize, y: isize, z: isize}

fn f(p: &Cell<Point>) {
    assert_eq!(p.get().z, 12);
    p.set(Point {x: 10, y: 11, z: 13});
    assert_eq!(p.get().z, 13);
}

pub fn main() {
    let a: Point = Point {x: 10, y: 11, z: 12};
    let b: &Cell<Point> = &Cell::new(a);
    assert_eq!(b.get().z, 12);
    f(b);
    assert_eq!(a.z, 12);
    assert_eq!(b.get().z, 13);
}