2018-12-17 03:21:47 +00:00
|
|
|
struct Point {
|
2015-01-08 10:54:35 +00:00
|
|
|
x: isize,
|
|
|
|
y: isize,
|
2013-01-08 00:57:43 +00:00
|
|
|
}
|
|
|
|
|
2018-12-17 03:21:47 +00:00
|
|
|
fn x_coord<'r>(p: &'r Point) -> &'r isize {
|
2014-04-16 22:58:55 +00:00
|
|
|
return &p.x;
|
2013-01-08 00:57:43 +00:00
|
|
|
}
|
2014-04-16 22:58:55 +00:00
|
|
|
|
2018-12-17 03:21:47 +00:00
|
|
|
fn foo<'a>(p: Box<Point>) -> &'a isize {
|
2019-04-22 07:40:08 +00:00
|
|
|
let xc = x_coord(&*p);
|
2014-04-16 22:58:55 +00:00
|
|
|
assert_eq!(*xc, 3);
|
2019-04-22 07:40:08 +00:00
|
|
|
return xc; //~ ERROR cannot return value referencing local data `*p`
|
2014-04-16 22:58:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|