rust/src/test/run-pass/exterior.rs
2018-12-25 21:08:33 -07:00

23 lines
446 B
Rust

#![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);
}