(index<- ) ./libstd/reference.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 //! Utilities for references
12
13 #[cfg(not(test))]
14 use cmp::{Eq, Ord, Ordering, TotalEq, TotalOrd};
15
16 // Equality for region pointers
17 #[cfg(not(test))]
18 impl<'a, T: Eq> Eq for &'a T {
19 #[inline]
20 fn eq(&self, other: & &'a T) -> bool {
21 *(*self) == *(*other)
22 }
23 #[inline]
24 fn ne(&self, other: & &'a T) -> bool {
25 *(*self) != *(*other)
26 }
27 }
28
29 // Comparison for region pointers
30 #[cfg(not(test))]
31 impl<'a, T: Ord> Ord for &'a T {
32 #[inline]
33 fn lt(&self, other: & &'a T) -> bool {
34 *(*self) < *(*other)
35 }
36 #[inline]
37 fn le(&self, other: & &'a T) -> bool {
38 *(*self) <= *(*other)
39 }
40 #[inline]
41 fn ge(&self, other: & &'a T) -> bool {
42 *(*self) >= *(*other)
43 }
44 #[inline]
45 fn gt(&self, other: & &'a T) -> bool {
46 *(*self) > *(*other)
47 }
48 }
49
50 #[cfg(not(test))]
51 impl<'a, T: TotalOrd> TotalOrd for &'a T {
52 #[inline]
53 fn cmp(&self, other: & &'a T) -> Ordering { (**self).cmp(*other) }
54 }
55
56 #[cfg(not(test))]
57 impl<'a, T: TotalEq> TotalEq for &'a T {}