]>
Commit | Line | Data |
---|---|---|
476ff2be SL |
1 | pub use self::imp::*; |
2 | ||
3 | #[cfg(not(dox))] | |
4 | mod imp { | |
5 | pub use core::option::Option; | |
6 | pub use core::clone::Clone; | |
7 | pub use core::marker::Copy; | |
8 | pub use core::mem; | |
9 | } | |
10 | ||
11 | #[cfg(dox)] | |
12 | mod imp { | |
13 | pub enum Option<T> { | |
14 | Some(T), | |
15 | None, | |
16 | } | |
17 | impl<T: Copy> Copy for Option<T> {} | |
18 | impl<T: Clone> Clone for Option<T> { | |
19 | fn clone(&self) -> Option<T> { loop {} } | |
20 | } | |
21 | ||
22 | pub trait Clone { | |
23 | fn clone(&self) -> Self; | |
24 | } | |
25 | ||
26 | #[lang = "copy"] | |
27 | pub trait Copy {} | |
28 | ||
041b39d2 XL |
29 | #[lang = "freeze"] |
30 | pub trait Freeze {} | |
31 | ||
476ff2be SL |
32 | #[lang = "sync"] |
33 | pub trait Sync {} | |
34 | impl<T> Sync for T {} | |
35 | ||
36 | #[lang = "sized"] | |
37 | pub trait Sized {} | |
38 | ||
39 | macro_rules! each_int { | |
40 | ($mac:ident) => ( | |
41 | $mac!(u8); | |
42 | $mac!(u16); | |
43 | $mac!(u32); | |
44 | $mac!(u64); | |
45 | $mac!(usize); | |
8bb4bdeb XL |
46 | each_signed_int!($mac); |
47 | ) | |
48 | } | |
49 | ||
50 | macro_rules! each_signed_int { | |
51 | ($mac:ident) => ( | |
476ff2be SL |
52 | $mac!(i8); |
53 | $mac!(i16); | |
54 | $mac!(i32); | |
55 | $mac!(i64); | |
56 | $mac!(isize); | |
57 | ) | |
58 | } | |
59 | ||
60 | #[lang = "div"] | |
61 | pub trait Div<RHS> { | |
62 | type Output; | |
63 | fn div(self, rhs: RHS) -> Self::Output; | |
64 | } | |
65 | ||
476ff2be SL |
66 | #[lang = "shl"] |
67 | pub trait Shl<RHS> { | |
68 | type Output; | |
69 | fn shl(self, rhs: RHS) -> Self::Output; | |
70 | } | |
71 | ||
476ff2be SL |
72 | #[lang = "mul"] |
73 | pub trait Mul<RHS=Self> { | |
74 | type Output; | |
75 | fn mul(self, rhs: RHS) -> Self::Output; | |
76 | } | |
77 | ||
476ff2be SL |
78 | #[lang = "sub"] |
79 | pub trait Sub<RHS=Self> { | |
80 | type Output; | |
81 | fn sub(self, rhs: RHS) -> Self::Output; | |
82 | } | |
83 | ||
476ff2be SL |
84 | #[lang = "bitor"] |
85 | pub trait Bitor<RHS=Self> { | |
86 | type Output; | |
87 | fn bitor(self, rhs: RHS) -> Self::Output; | |
88 | } | |
89 | ||
8bb4bdeb XL |
90 | #[lang = "neg"] |
91 | pub trait Neg { | |
92 | type Output; | |
93 | fn neg(self) -> Self::Output; | |
94 | } | |
95 | ||
8bb4bdeb XL |
96 | #[lang = "not"] |
97 | pub trait Not { | |
98 | type Output; | |
99 | fn not(self) -> Self::Output; | |
100 | } | |
101 | ||
abe05a73 XL |
102 | #[lang = "add"] |
103 | pub trait Add<RHS = Self> { | |
104 | type Output; | |
105 | fn add(self, r: RHS) -> Self::Output; | |
106 | } | |
107 | ||
108 | macro_rules! impl_traits { | |
8bb4bdeb | 109 | ($($i:ident)*) => ($( |
abe05a73 XL |
110 | impl Div<$i> for $i { |
111 | type Output = $i; | |
112 | fn div(self, rhs: $i) -> $i { self / rhs } | |
113 | } | |
114 | impl Shl<$i> for $i { | |
115 | type Output = $i; | |
116 | fn shl(self, rhs: $i) -> $i { self << rhs } | |
117 | } | |
118 | impl Mul for $i { | |
119 | type Output = $i; | |
120 | fn mul(self, rhs: $i) -> $i { self * rhs } | |
121 | } | |
122 | ||
123 | impl Sub for $i { | |
124 | type Output = $i; | |
125 | fn sub(self, rhs: $i) -> $i { self - rhs } | |
126 | } | |
127 | impl Bitor for $i { | |
128 | type Output = $i; | |
129 | fn bitor(self, rhs: $i) -> $i { self | rhs } | |
130 | } | |
131 | impl Neg for $i { | |
132 | type Output = $i; | |
133 | fn neg(self) -> $i { -self } | |
134 | } | |
8bb4bdeb XL |
135 | impl Not for $i { |
136 | type Output = $i; | |
137 | fn not(self) -> $i { !self } | |
138 | } | |
abe05a73 XL |
139 | impl Add<$i> for $i { |
140 | type Output = $i; | |
141 | fn add(self, other: $i) -> $i { self + other } | |
142 | } | |
8bb4bdeb XL |
143 | )*) |
144 | } | |
abe05a73 | 145 | each_int!(impl_traits); |
8bb4bdeb | 146 | |
476ff2be SL |
147 | pub mod mem { |
148 | pub fn size_of_val<T>(_: &T) -> usize { 4 } | |
149 | } | |
150 | } |