1 // Copyright 2013 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 #![feature(macro_rules)]
13 use std::mem::size_of;
15 #[deriving(PartialEq, Show)]
16 enum Either<T, U> { Left(T), Right(U) }
19 ($t:ty, $sz:expr, $($e:expr, $s:expr),*) => {{
20 assert_eq!(size_of::<$t>(), $sz);
25 assert_eq!(format!("{}", v).as_slice(), $s);
26 assert_eq!(format!("{}", S).as_slice(), $s);
34 Some(129u8), "Some(129)");
35 check!(Option<i16>, 4,
37 Some(-20000i16), "Some(-20000)");
38 check!(Either<u8, i8>, 2,
39 Left(132u8), "Left(132)",
40 Right(-32i8), "Right(-32)");
41 check!(Either<u8, i16>, 4,
42 Left(132u8), "Left(132)",
43 Right(-20000i16), "Right(-20000)");