1 // Copyright 2014 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.
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.
11 #![feature(box_syntax)]
13 #[derive(PartialEq, Debug)]
19 assert_eq!(self.x, 22);
23 #[derive(PartialEq, Debug)]
29 fn foo() -> Result<Foo, isize> {
36 fn baz() -> Result<Foo, isize> {
43 // explicit immediate return
48 // implicit immediate return
53 // implicit outptr return
54 fn cc() -> Result<isize, isize> {
58 // explicit outptr return
59 fn dd() -> Result<isize, isize> {
64 fn aaa(&self) -> isize {
67 fn bbb(&self) -> isize {
70 fn ccc(&self) -> Result<isize, isize> {
73 fn ddd(&self) -> Result<isize, isize> {
81 assert_eq!(foo(), Err(32));
82 assert_eq!(baz(), Err(32));
86 assert_eq!(cc().unwrap(), 3);
87 assert_eq!(dd().unwrap(), 3);
89 let i = box 32isize as Box<A>;
90 assert_eq!(i.aaa(), 3);
91 let i = box 32isize as Box<A>;
92 assert_eq!(i.bbb(), 3);
93 let i = box 32isize as Box<A>;
94 assert_eq!(i.ccc().unwrap(), 3);
95 let i = box 32isize as Box<A>;
96 assert_eq!(i.ddd().unwrap(), 3);