os-rust/tests/ui/regions/regions-infer-borrow-scope.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

15 lines
242 B
Rust
Raw Normal View History

// run-pass
#![allow(dead_code)]
struct Point {x: isize, y: isize}
2012-07-06 09:14:57 -07:00
fn x_coord(p: &Point) -> &isize {
2012-08-01 17:30:05 -07:00
return &p.x;
2012-07-06 09:14:57 -07:00
}
pub fn main() {
let p: Box<_> = Box::new(Point {x: 3, y: 4});
let xc = x_coord(&*p);
assert_eq!(*xc, 3);
2012-07-06 09:14:57 -07:00
}