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, T> {
|
|
|
|
fn get(&self) -> &'a T;
|
|
|
|
}
|
|
|
|
|
2014-08-28 01:46:52 +00:00
|
|
|
struct Box<'a, T:'a> {
|
2014-03-07 07:43:39 +00: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 10:54:35 +00:00
|
|
|
fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize {
|
2015-01-12 06:01:44 +00:00
|
|
|
g1.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() {
|
|
|
|
}
|