]> git.proxmox.com Git - rustc.git/blob - src/liblibc/src/dox.rs
New upstream version 1.20.0+dfsg1
[rustc.git] / src / liblibc / src / dox.rs
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
29 #[lang = "freeze"]
30 pub trait Freeze {}
31
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);
46 each_signed_int!($mac);
47 )
48 }
49
50 macro_rules! each_signed_int {
51 ($mac:ident) => (
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
66 macro_rules! impl_div {
67 ($($i:ident)*) => ($(
68 impl Div<$i> for $i {
69 type Output = $i;
70 fn div(self, rhs: $i) -> $i { self / rhs }
71 }
72 )*)
73 }
74 each_int!(impl_div);
75
76 #[lang = "shl"]
77 pub trait Shl<RHS> {
78 type Output;
79 fn shl(self, rhs: RHS) -> Self::Output;
80 }
81
82 macro_rules! impl_shl {
83 ($($i:ident)*) => ($(
84 impl Shl<$i> for $i {
85 type Output = $i;
86 fn shl(self, rhs: $i) -> $i { self << rhs }
87 }
88 )*)
89 }
90 each_int!(impl_shl);
91
92 #[lang = "mul"]
93 pub trait Mul<RHS=Self> {
94 type Output;
95 fn mul(self, rhs: RHS) -> Self::Output;
96 }
97
98 macro_rules! impl_mul {
99 ($($i:ident)*) => ($(
100 impl Mul for $i {
101 type Output = $i;
102 fn mul(self, rhs: $i) -> $i { self * rhs }
103 }
104 )*)
105 }
106 each_int!(impl_mul);
107
108 #[lang = "sub"]
109 pub trait Sub<RHS=Self> {
110 type Output;
111 fn sub(self, rhs: RHS) -> Self::Output;
112 }
113
114 macro_rules! impl_sub {
115 ($($i:ident)*) => ($(
116 impl Sub for $i {
117 type Output = $i;
118 fn sub(self, rhs: $i) -> $i { self - rhs }
119 }
120 )*)
121 }
122 each_int!(impl_sub);
123
124 #[lang = "bitor"]
125 pub trait Bitor<RHS=Self> {
126 type Output;
127 fn bitor(self, rhs: RHS) -> Self::Output;
128 }
129
130 macro_rules! impl_bitor {
131 ($($i:ident)*) => ($(
132 impl Bitor for $i {
133 type Output = $i;
134 fn bitor(self, rhs: $i) -> $i { self | rhs }
135 }
136 )*)
137 }
138 each_int!(impl_bitor);
139
140 #[lang = "neg"]
141 pub trait Neg {
142 type Output;
143 fn neg(self) -> Self::Output;
144 }
145
146 macro_rules! impl_neg {
147 ($($i:ident)*) => ($(
148 impl Neg for $i {
149 type Output = $i;
150 fn neg(self) -> $i { -self }
151 }
152 )*)
153 }
154 each_signed_int!(impl_neg);
155
156 #[lang = "not"]
157 pub trait Not {
158 type Output;
159 fn not(self) -> Self::Output;
160 }
161
162 macro_rules! impl_not {
163 ($($i:ident)*) => ($(
164 impl Not for $i {
165 type Output = $i;
166 fn not(self) -> $i { !self }
167 }
168 )*)
169 }
170 each_int!(impl_not);
171
172 pub mod mem {
173 pub fn size_of_val<T>(_: &T) -> usize { 4 }
174 }
175 }