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 #![allow(unknown_features)]
12 #![feature(box_syntax)]
14 #[derive(PartialEq, Show)]
20 assert_eq!(self.x, 22);
24 #[derive(PartialEq, Show)]
30 fn foo() -> Result<Foo, int> {
37 fn baz() -> Result<Foo, int> {
44 // explicit immediate return
49 // implicit immediate return
54 // implicit outptr return
55 fn cc() -> Result<int, int> {
59 // explicit outptr return
60 fn dd() -> Result<int, int> {
65 fn aaa(&self) -> int {
68 fn bbb(&self) -> int {
71 fn ccc(&self) -> Result<int, int> {
74 fn ddd(&self) -> Result<int, int> {
82 assert_eq!(foo(), Err(32));
83 assert_eq!(baz(), Err(32));
87 assert_eq!(cc().unwrap(), 3);
88 assert_eq!(dd().unwrap(), 3);
90 let i = box 32i as Box<A>;
91 assert_eq!(i.aaa(), 3);
92 let i = box 32i as Box<A>;
93 assert_eq!(i.bbb(), 3);
94 let i = box 32i as Box<A>;
95 assert_eq!(i.ccc().unwrap(), 3);
96 let i = box 32i as Box<A>;
97 assert_eq!(i.ddd().unwrap(), 3);