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, T> {
|
|
|
|
fn get(&self) -> &'a T;
|
|
|
|
}
|
|
|
|
|
2014-08-27 21:46:52 -04:00
|
|
|
struct Box<'a, T:'a> {
|
2014-03-07 08:43:39 +01:00
|
|
|
t: &'a T
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a,T:Clone> GetRef<'a,T> for Box<'a,T> {
|
|
|
|
fn get(&self) -> &'a T {
|
|
|
|
self.t
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-08 21:54:35 +11:00
|
|
|
fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize {
|
2015-01-12 01:01:44 -05:00
|
|
|
g1.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() {
|
|
|
|
}
|