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