2012-12-10 19:32:48 -06:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2015-01-07 19:41:23 -06:00
|
|
|
#![feature(box_syntax)]
|
|
|
|
|
2013-03-01 21:57:05 -06:00
|
|
|
struct clam {
|
2014-12-05 20:12:25 -06:00
|
|
|
x: Box<isize>,
|
|
|
|
y: Box<isize>,
|
2013-03-01 21:57:05 -06:00
|
|
|
}
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2013-03-01 21:57:05 -06:00
|
|
|
struct fish {
|
2014-12-05 20:12:25 -06:00
|
|
|
a: Box<isize>,
|
2013-03-01 21:57:05 -06:00
|
|
|
}
|
2010-07-19 21:06:55 -05:00
|
|
|
|
|
|
|
fn main() {
|
2014-10-02 00:10:09 -05:00
|
|
|
let a: clam = clam{x: box 1, y: box 2};
|
|
|
|
let b: clam = clam{x: box 10, y: box 20};
|
2014-12-05 20:12:25 -06:00
|
|
|
let z: isize = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `Box<isize>`
|
2014-10-02 00:10:09 -05:00
|
|
|
println!("{}", z);
|
2013-05-18 21:02:45 -05:00
|
|
|
assert_eq!(z, 21);
|
2014-10-02 00:10:09 -05:00
|
|
|
let forty: fish = fish{a: box 40};
|
|
|
|
let two: fish = fish{a: box 2};
|
2015-01-08 04:54:35 -06:00
|
|
|
let answer: isize = forty.a + two.a;
|
2014-12-05 20:12:25 -06:00
|
|
|
//~^ ERROR binary operation `+` cannot be applied to type `Box<isize>`
|
2014-10-02 00:10:09 -05:00
|
|
|
println!("{}", answer);
|
2013-05-18 21:02:45 -05:00
|
|
|
assert_eq!(answer, 42);
|
2011-08-12 18:33:53 -05:00
|
|
|
}
|