2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2015-11-23 14:57:28 -05:00
|
|
|
fn main() {
|
|
|
|
let x = X(15);
|
|
|
|
let y = x.foo();
|
|
|
|
println!("{:?}",y);
|
|
|
|
}
|
|
|
|
|
2015-12-15 04:31:58 -05:00
|
|
|
trait Foo
|
|
|
|
where for<'a> &'a Self: Bar
|
|
|
|
{
|
2015-11-23 14:57:28 -05:00
|
|
|
fn foo<'a>(&'a self) -> <&'a Self as Bar>::Output;
|
|
|
|
}
|
|
|
|
|
|
|
|
trait Bar {
|
|
|
|
type Output;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct X(i32);
|
|
|
|
|
|
|
|
impl<'a> Bar for &'a X {
|
|
|
|
type Output = &'a i32;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Foo for X {
|
|
|
|
fn foo<'a>(&'a self) -> <&'a Self as Bar>::Output {
|
|
|
|
&self.0
|
|
|
|
}
|
|
|
|
}
|