Alex Crichton | 24abc4f | 2015-09-16 23:54:56 -0700 | [diff] [blame] | 1 | pub use self::imp::*; |
| 2 | |
| 3 | #[cfg(not(dox))] |
| 4 | mod imp { |
Alex Crichton | f7efe34 | 2015-11-02 14:26:04 -0800 | [diff] [blame] | 5 | pub use core::option::Option; |
| 6 | pub use core::clone::Clone; |
| 7 | pub use core::marker::Copy; |
| 8 | pub use core::mem; |
Alex Crichton | 24abc4f | 2015-09-16 23:54:56 -0700 | [diff] [blame] | 9 | } |
| 10 | |
| 11 | #[cfg(dox)] |
| 12 | mod imp { |
| 13 | pub enum Option<T> { |
| 14 | Some(T), |
| 15 | None, |
| 16 | } |
Alex Crichton | 0262b07 | 2015-09-17 17:53:03 -0700 | [diff] [blame] | 17 | impl<T: Copy> Copy for Option<T> {} |
Alex Crichton | 97a2c17 | 2015-09-17 17:28:45 -0700 | [diff] [blame] | 18 | impl<T: Clone> Clone for Option<T> { |
| 19 | fn clone(&self) -> Option<T> { loop {} } |
| 20 | } |
Alex Crichton | 24abc4f | 2015-09-16 23:54:56 -0700 | [diff] [blame] | 21 | |
| 22 | pub trait Clone { |
| 23 | fn clone(&self) -> Self; |
| 24 | } |
| 25 | |
| 26 | #[lang = "copy"] |
| 27 | pub trait Copy {} |
| 28 | |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 29 | #[lang = "sync"] |
| 30 | pub trait Sync {} |
| 31 | impl<T> Sync for T {} |
| 32 | |
Alex Crichton | 24abc4f | 2015-09-16 23:54:56 -0700 | [diff] [blame] | 33 | #[lang = "sized"] |
| 34 | pub trait Sized {} |
| 35 | |
| 36 | macro_rules! each_int { |
| 37 | ($mac:ident) => ( |
| 38 | $mac!(u8); |
| 39 | $mac!(u16); |
| 40 | $mac!(u32); |
| 41 | $mac!(u64); |
| 42 | $mac!(usize); |
| 43 | $mac!(i8); |
| 44 | $mac!(i16); |
| 45 | $mac!(i32); |
| 46 | $mac!(i64); |
| 47 | $mac!(isize); |
| 48 | ) |
| 49 | } |
| 50 | |
Alex Crichton | 07d3a0d | 2015-10-30 10:21:32 -0700 | [diff] [blame] | 51 | #[lang = "div"] |
| 52 | pub trait Div<RHS> { |
| 53 | type Output; |
| 54 | fn div(self, rhs: RHS) -> Self::Output; |
| 55 | } |
| 56 | |
| 57 | macro_rules! impl_div { |
| 58 | ($($i:ident)*) => ($( |
| 59 | impl Div<$i> for $i { |
| 60 | type Output = $i; |
| 61 | fn div(self, rhs: $i) -> $i { self / rhs } |
| 62 | } |
| 63 | )*) |
| 64 | } |
| 65 | each_int!(impl_div); |
| 66 | |
Alex Crichton | 24abc4f | 2015-09-16 23:54:56 -0700 | [diff] [blame] | 67 | #[lang = "shl"] |
| 68 | pub trait Shl<RHS> { |
| 69 | type Output; |
| 70 | fn shl(self, rhs: RHS) -> Self::Output; |
| 71 | } |
| 72 | |
| 73 | macro_rules! impl_shl { |
| 74 | ($($i:ident)*) => ($( |
| 75 | impl Shl<$i> for $i { |
| 76 | type Output = $i; |
| 77 | fn shl(self, rhs: $i) -> $i { self << rhs } |
| 78 | } |
| 79 | )*) |
| 80 | } |
| 81 | each_int!(impl_shl); |
| 82 | |
| 83 | #[lang = "mul"] |
| 84 | pub trait Mul<RHS=Self> { |
| 85 | type Output; |
| 86 | fn mul(self, rhs: RHS) -> Self::Output; |
| 87 | } |
| 88 | |
| 89 | macro_rules! impl_mul { |
| 90 | ($($i:ident)*) => ($( |
| 91 | impl Mul for $i { |
| 92 | type Output = $i; |
| 93 | fn mul(self, rhs: $i) -> $i { self * rhs } |
| 94 | } |
| 95 | )*) |
| 96 | } |
| 97 | each_int!(impl_mul); |
| 98 | |
| 99 | #[lang = "sub"] |
| 100 | pub trait Sub<RHS=Self> { |
| 101 | type Output; |
| 102 | fn sub(self, rhs: RHS) -> Self::Output; |
| 103 | } |
| 104 | |
| 105 | macro_rules! impl_sub { |
| 106 | ($($i:ident)*) => ($( |
| 107 | impl Sub for $i { |
| 108 | type Output = $i; |
| 109 | fn sub(self, rhs: $i) -> $i { self - rhs } |
| 110 | } |
| 111 | )*) |
| 112 | } |
| 113 | each_int!(impl_sub); |
| 114 | |
| 115 | #[lang = "bitor"] |
| 116 | pub trait Bitor<RHS=Self> { |
| 117 | type Output; |
| 118 | fn bitor(self, rhs: RHS) -> Self::Output; |
| 119 | } |
| 120 | |
| 121 | macro_rules! impl_bitor { |
| 122 | ($($i:ident)*) => ($( |
| 123 | impl Bitor for $i { |
| 124 | type Output = $i; |
| 125 | fn bitor(self, rhs: $i) -> $i { self | rhs } |
| 126 | } |
| 127 | )*) |
| 128 | } |
| 129 | each_int!(impl_bitor); |
Alex Crichton | 07d3a0d | 2015-10-30 10:21:32 -0700 | [diff] [blame] | 130 | |
| 131 | pub mod mem { |
| 132 | pub fn size_of_val<T>(_: &T) -> usize { 4 } |
| 133 | } |
Alex Crichton | 24abc4f | 2015-09-16 23:54:56 -0700 | [diff] [blame] | 134 | } |