2014-03-07 07:43:39 +00:00
|
|
|
// Tests that you can use a fn lifetime parameter as part of
|
|
|
|
// the value for a type parameter in a bound.
|
|
|
|
|
|
|
|
trait GetRef<'a> {
|
2015-01-08 10:54:35 +00:00
|
|
|
fn get(&self) -> &'a isize;
|
2014-03-07 07:43:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Box<'a> {
|
2015-01-08 10:54:35 +00:00
|
|
|
t: &'a isize
|
2014-03-07 07:43:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> GetRef<'a> for Box<'a> {
|
2015-01-08 10:54:35 +00:00
|
|
|
fn get(&self) -> &'a isize {
|
2014-03-07 07:43:39 +00:00
|
|
|
self.t
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Box<'a> {
|
2015-01-08 10:54:35 +00:00
|
|
|
fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize {
|
2015-01-12 06:01:44 +00:00
|
|
|
g2.get()
|
2022-04-01 17:13:25 +00:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2014-03-07 07:43:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|