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