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 use std::mem::size_of;
13 #[derive(PartialEq, Show)]
14 enum Either<T, U> { Left(T), Right(U) }
17 ($t:ty, $sz:expr, $($e:expr, $s:expr),*) => {{
18 assert_eq!(size_of::<$t>(), $sz);
23 assert_eq!(format!("{:?}", v).as_slice(), $s);
24 assert_eq!(format!("{:?}", S).as_slice(), $s);
32 Some(129u8), "Some(129u8)");
33 check!(Option<i16>, 4,
35 Some(-20000i16), "Some(-20000i16)");
36 check!(Either<u8, i8>, 2,
37 Either::Left(132u8), "Left(132u8)",
38 Either::Right(-32i8), "Right(-32i8)");
39 check!(Either<u8, i16>, 4,
40 Either::Left(132u8), "Left(132u8)",
41 Either::Right(-20000i16), "Right(-20000i16)");