]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/objects-owned-object-owned-method.rs
Imported Upstream version 1.0.0~beta.3
[rustc.git] / src / test / run-pass / objects-owned-object-owned-method.rs
CommitLineData
223e47cc
LB
1// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
1a4d82fc
JJ
11// Test invoked `&self` methods on owned objects where the values
12// closed over contain managed values. This implies that the boxes
13// will have headers that must be skipped over.
14
c34b1796 15
1a4d82fc
JJ
16#![allow(unknown_features)]
17#![feature(box_syntax)]
970d7e83
LB
18
19trait FooTrait {
c34b1796 20 fn foo(self: Box<Self>) -> usize;
970d7e83
LB
21}
22
23struct BarStruct {
c34b1796 24 x: usize
970d7e83
LB
25}
26
27impl FooTrait for BarStruct {
c34b1796 28 fn foo(self: Box<BarStruct>) -> usize {
970d7e83
LB
29 self.x
30 }
31}
32
223e47cc 33pub fn main() {
1a4d82fc
JJ
34 let foo = box BarStruct{ x: 22 } as Box<FooTrait>;
35 assert_eq!(22, foo.foo());
223e47cc 36}