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.
12 #[deriving(PartialEq, Show)]
18 assert_eq!(self.x, 22);
22 #[deriving(PartialEq, Show)]
28 fn foo() -> Result<Foo, int> {
35 fn baz() -> Result<Foo, int> {
42 // explicit immediate return
47 // implicit immediate return
52 // implicit outptr return
53 fn cc() -> Result<int, int> {
57 // explicit outptr return
58 fn dd() -> Result<int, int> {
69 fn ccc(self) -> Result<int, int> {
72 fn ddd(self) -> Result<int, int> {
80 assert_eq!(foo(), Err(32));
81 assert_eq!(baz(), Err(32));
85 assert_eq!(cc().unwrap(), 3);
86 assert_eq!(dd().unwrap(), 3);
88 let i = box 32i as Box<A>;
89 assert_eq!(i.aaa(), 3);
90 let i = box 32i as Box<A>;
91 assert_eq!(i.bbb(), 3);
92 let i = box 32i as Box<A>;
93 assert_eq!(i.ccc().unwrap(), 3);
94 let i = box 32i as Box<A>;
95 assert_eq!(i.ddd().unwrap(), 3);