blob: 0d675c16d1aad119c6731ee717c338e9e0b610f2 [file] [log] [blame]
Philipp Brüschweilerde471a22013-06-22 07:37:401// 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
Niko Matsakisb402e342013-08-11 17:58:4811// 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
Philipp Brüschweilerde471a22013-06-22 07:37:4015trait FooTrait {
Niko Matsakisb402e342013-08-11 17:58:4816 fn foo(~self) -> uint;
Philipp Brüschweilerde471a22013-06-22 07:37:4017}
18
19struct BarStruct {
20 x: uint
21}
22
23impl FooTrait for BarStruct {
Niko Matsakisb402e342013-08-11 17:58:4824 fn foo(~self) -> uint {
Philipp Brüschweilerde471a22013-06-22 07:37:4025 self.x
26 }
27}
28
29pub fn main() {
Niko Matsakisb402e342013-08-11 17:58:4830 let foo = ~BarStruct{ x: 22 } as ~FooTrait;
31 assert_eq!(22, foo.foo());
Philipp Brüschweilerde471a22013-06-22 07:37:4032}