]>
Commit | Line | Data |
---|---|---|
7453a54e SL |
1 | // Copyright 2015 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. | |
4 | // | |
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. | |
10 | ||
11 | // `#[derive(Trait)]` works for empty structs/variants with braces | |
12 | ||
13 | #![feature(rustc_private)] | |
14 | ||
15 | extern crate serialize as rustc_serialize; | |
16 | ||
17 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, | |
18 | Default, Debug, RustcEncodable, RustcDecodable)] | |
19 | struct S {} | |
20 | ||
21 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, | |
22 | Debug, RustcEncodable, RustcDecodable)] | |
23 | enum E { | |
24 | V {}, | |
25 | U, | |
26 | } | |
27 | ||
28 | fn main() { | |
29 | let s = S {}; | |
30 | let s1 = s; | |
31 | let s2 = s.clone(); | |
32 | assert_eq!(s, s1); | |
33 | assert_eq!(s, s2); | |
34 | assert!(!(s < s1)); | |
35 | assert_eq!(format!("{:?}", s), "S"); | |
36 | ||
37 | let e = E::V {}; | |
38 | let e1 = e; | |
39 | let e2 = e.clone(); | |
40 | assert_eq!(e, e1); | |
41 | assert_eq!(e, e2); | |
42 | assert!(!(e < e1)); | |
43 | assert_eq!(format!("{:?}", e), "V"); | |
44 | } |