2014-03-07 08:43:39 +01: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 21:54:35 +11:00
|
|
|
fn get(&self) -> &'a isize;
|
2014-03-07 08:43:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Box<'a> {
|
2015-01-08 21:54:35 +11:00
|
|
|
t: &'a isize
|
2014-03-07 08:43:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> GetRef<'a> for Box<'a> {
|
2015-01-08 21:54:35 +11:00
|
|
|
fn get(&self) -> &'a isize {
|
2014-03-07 08:43:39 +01:00
|
|
|
self.t
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Box<'a> {
|
2015-01-08 21:54:35 +11:00
|
|
|
fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize {
|
2015-01-12 01:01:44 -05:00
|
|
|
g2.get()
|
2022-04-01 13:13:25 -04:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2014-03-07 08:43:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|