2015-01-08 01:41:23 +00:00
|
|
|
#![feature(box_syntax)]
|
|
|
|
|
2018-12-17 03:21:47 +00:00
|
|
|
struct Clam {
|
2014-12-06 02:12:25 +00:00
|
|
|
x: Box<isize>,
|
|
|
|
y: Box<isize>,
|
2013-03-02 03:57:05 +00:00
|
|
|
}
|
2011-06-15 18:19:50 +00:00
|
|
|
|
2018-12-17 03:21:47 +00:00
|
|
|
struct Fish {
|
2014-12-06 02:12:25 +00:00
|
|
|
a: Box<isize>,
|
2013-03-02 03:57:05 +00:00
|
|
|
}
|
2010-07-20 02:06:55 +00:00
|
|
|
|
|
|
|
fn main() {
|
2018-12-17 03:21:47 +00:00
|
|
|
let a: Clam = Clam{x: box 1, y: box 2};
|
|
|
|
let b: Clam = Clam{x: box 10, y: box 20};
|
2017-01-21 14:40:31 +00:00
|
|
|
let z: isize = a.x + b.y;
|
2019-12-11 22:11:32 +00:00
|
|
|
//~^ ERROR cannot add `std::boxed::Box<isize>` to `std::boxed::Box<isize>`
|
2014-10-02 05:10:09 +00:00
|
|
|
println!("{}", z);
|
2013-05-19 02:02:45 +00:00
|
|
|
assert_eq!(z, 21);
|
2018-12-17 03:21:47 +00:00
|
|
|
let forty: Fish = Fish{a: box 40};
|
|
|
|
let two: Fish = Fish{a: box 2};
|
2015-01-08 10:54:35 +00:00
|
|
|
let answer: isize = forty.a + two.a;
|
2019-12-11 22:11:32 +00:00
|
|
|
//~^ ERROR cannot add `std::boxed::Box<isize>` to `std::boxed::Box<isize>`
|
2014-10-02 05:10:09 +00:00
|
|
|
println!("{}", answer);
|
2013-05-19 02:02:45 +00:00
|
|
|
assert_eq!(answer, 42);
|
2011-08-12 23:33:53 +00:00
|
|
|
}
|