blob: c7d3dc9c2deba67253d7e0f9a5c72495cbae1a2d [file] [log] [blame]
Alex Crichton24abc4f2015-09-16 23:54:56 -07001pub use self::imp::*;
2
3#[cfg(not(dox))]
4mod imp {
Alex Crichtonf7efe342015-11-02 14:26:04 -08005 pub use core::option::Option;
6 pub use core::clone::Clone;
7 pub use core::marker::Copy;
8 pub use core::mem;
Alex Crichton24abc4f2015-09-16 23:54:56 -07009}
10
11#[cfg(dox)]
12mod imp {
13 pub enum Option<T> {
14 Some(T),
15 None,
16 }
Alex Crichton0262b072015-09-17 17:53:03 -070017 impl<T: Copy> Copy for Option<T> {}
Alex Crichton97a2c172015-09-17 17:28:45 -070018 impl<T: Clone> Clone for Option<T> {
19 fn clone(&self) -> Option<T> { loop {} }
20 }
Alex Crichton24abc4f2015-09-16 23:54:56 -070021
22 pub trait Clone {
23 fn clone(&self) -> Self;
24 }
25
26 #[lang = "copy"]
27 pub trait Copy {}
28
Alex Crichton8dce9ad2015-12-03 11:44:14 -080029 #[lang = "sync"]
30 pub trait Sync {}
31 impl<T> Sync for T {}
32
Alex Crichton24abc4f2015-09-16 23:54:56 -070033 #[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 Crichton07d3a0d2015-10-30 10:21:32 -070051 #[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 Crichton24abc4f2015-09-16 23:54:56 -070067 #[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 Crichton07d3a0d2015-10-30 10:21:32 -0700130
131 pub mod mem {
132 pub fn size_of_val<T>(_: &T) -> usize { 4 }
133 }
Alex Crichton24abc4f2015-09-16 23:54:56 -0700134}