summaryrefslogtreecommitdiffstats
path: root/tests/ui/self/arbitrary_self_types_trait.rs
blob: c4651ec717787edd9faf1e4e4282554e9682de0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// run-pass
#![allow(unused_allocation)]

use std::rc::Rc;

trait Trait {
    fn trait_method<'a>(self: &'a Box<Rc<Self>>) -> &'a [i32];
}

impl Trait for Vec<i32> {
    fn trait_method<'a>(self: &'a Box<Rc<Self>>) -> &'a [i32] {
        &***self
    }
}

fn main() {
    let v = vec![1, 2, 3];

    assert_eq!(&[1, 2, 3], Box::new(Rc::new(v)).trait_method());
}