]>
Commit | Line | Data |
---|---|---|
416331ca | 1 | // run-pass |
1a4d82fc JJ |
2 | // Test invoked `&self` methods on owned objects where the values |
3 | // closed over contain managed values. This implies that the boxes | |
4 | // will have headers that must be skipped over. | |
5 | ||
970d7e83 | 6 | trait FooTrait { |
c34b1796 | 7 | fn foo(self: Box<Self>) -> usize; |
970d7e83 LB |
8 | } |
9 | ||
10 | struct BarStruct { | |
c34b1796 | 11 | x: usize |
970d7e83 LB |
12 | } |
13 | ||
14 | impl FooTrait for BarStruct { | |
c34b1796 | 15 | fn foo(self: Box<BarStruct>) -> usize { |
970d7e83 LB |
16 | self.x |
17 | } | |
18 | } | |
19 | ||
223e47cc | 20 | pub fn main() { |
c295e0f8 | 21 | let foo = Box::new(BarStruct{ x: 22 }) as Box<dyn FooTrait>; |
1a4d82fc | 22 | assert_eq!(22, foo.foo()); |
223e47cc | 23 | } |