(index<- ) ./libstd/unit.rs
git branch: * master c7553ea auto merge of #13609 : richo/rust/str-type-vim, r=alexcrichton
modified: Wed Mar 26 11:50:03 2014
1 // Copyright 2012-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.
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 //! Functions for the unit type.
12
13 #[cfg(not(test))]
14 use default::Default;
15 #[cfg(not(test))]
16 use cmp::{Eq, Equal, Ord, Ordering, TotalEq, TotalOrd};
17 use fmt;
18
19 #[cfg(not(test))]
20 impl Eq for () {
21 #[inline]
22 fn eq(&self, _other: &()) -> bool { true }
23 #[inline]
24 fn ne(&self, _other: &()) -> bool { false }
25 }
26
27 #[cfg(not(test))]
28 impl Ord for () {
29 #[inline]
30 fn lt(&self, _other: &()) -> bool { false }
31 }
32
33 #[cfg(not(test))]
34 impl TotalOrd for () {
35 #[inline]
36 fn cmp(&self, _other: &()) -> Ordering { Equal }
37 }
38
39 #[cfg(not(test))]
40 impl TotalEq for () {}
41
42 #[cfg(not(test))]
43 impl Default for () {
44 #[inline]
45 fn default() -> () { () }
46 }
47
48 impl fmt::Show for () {
49 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
50 f.pad("()")
51 }
52 }