]> git.lizzy.rs Git - rust.git/blob - src/libcore/core.rc
Merge remote-tracking branch 'brson/io'
[rust.git] / src / libcore / core.rc
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 /*!
12
13 # The Rust core library
14
15 The Rust core library provides runtime features required by the language,
16 including the task scheduler and memory allocators, as well as library
17 support for Rust built-in types, platform abstractions, and other commonly
18 used features.
19
20 `core` includes modules corresponding to each of the integer types, each of
21 the floating point types, the `bool` type, tuples, characters, strings
22 (`str`), vectors (`vec`), managed boxes (`managed`), owned boxes (`owned`),
23 and unsafe and borrowed pointers (`ptr`).  Additionally, `core` provides
24 pervasive types (`option` and `result`), task creation and communication
25 primitives (`task`, `comm`), platform abstractions (`os` and `path`), basic
26 I/O abstractions (`io`), common traits (`kinds`, `ops`, `cmp`, `num`,
27 `to_str`), and complete bindings to the C standard library (`libc`).
28
29 # Core injection and the Rust prelude
30
31 `core` is imported at the topmost level of every crate by default, as
32 if the first line of each crate was
33
34     extern mod core;
35
36 This means that the contents of core can be accessed from from any context
37 with the `core::` path prefix, as in `use core::vec`, `use core::task::spawn`,
38 etc.
39
40 Additionally, `core` contains a `prelude` module that reexports many of the
41 most common core modules, types and traits. The contents of the prelude are
42 imported into every *module* by default.  Implicitly, all modules behave as if
43 they contained the following prologue:
44
45     use core::prelude::*;
46
47 */
48
49
50 #[link(name = "core",
51        vers = "0.7-pre",
52        uuid = "c70c24a7-5551-4f73-8e37-380b11d80be8",
53        url = "https://github.com/mozilla/rust/tree/master/src/libcore")];
54
55 #[comment = "The Rust core library"];
56 #[license = "MIT/ASL2"];
57 #[crate_type = "lib"];
58
59
60 // Don't link to core. We are core.
61 #[no_core];
62
63 #[warn(vecs_implicitly_copyable)];
64 #[deny(non_camel_case_types)];
65 #[allow(deprecated_mutable_fields)];
66 #[allow(deprecated_drop)];
67
68 // Make core testable by not duplicating lang items. See #2912
69 #[cfg(test)] extern mod realcore(name = "core", vers = "0.7-pre");
70 #[cfg(test)] pub use kinds = realcore::kinds;
71 #[cfg(test)] pub use ops = realcore::ops;
72 #[cfg(test)] pub use cmp = realcore::cmp;
73
74 /* Reexported core operators */
75
76 pub use kinds::{Const, Copy, Owned, Durable};
77 pub use ops::{Drop};
78 #[cfg(stage0)]
79 pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not};
80 #[cfg(not(stage0))]
81 pub use ops::{Add, Sub, Mul, Quot, Rem, Neg, Not};
82 pub use ops::{BitAnd, BitOr, BitXor};
83 pub use ops::{Shl, Shr, Index};
84
85
86 /* Reexported types and traits */
87
88 pub use option::{Option, Some, None};
89 pub use result::{Result, Ok, Err};
90
91 pub use path::Path;
92 pub use path::GenericPath;
93 pub use path::WindowsPath;
94 pub use path::PosixPath;
95
96 pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
97 pub use str::{StrSlice};
98 pub use container::{Container, Mutable};
99 pub use vec::{CopyableVector, ImmutableVector};
100 pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
101 pub use vec::{OwnedVector, OwnedCopyableVector, MutableVector};
102 pub use old_iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
103 pub use old_iter::{CopyableOrderedIter, CopyableNonstrictIter};
104 pub use old_iter::{ExtendedMutableIter};
105 pub use iter::Times;
106
107 pub use num::{Num, NumCast};
108 pub use num::{Orderable, Signed, Unsigned, Round};
109 pub use num::{Algebraic, Trigonometric, Exponential, Hyperbolic};
110 pub use num::{Integer, Fractional, Real, RealExt};
111 pub use num::{Bitwise, BitCount, Bounded};
112 pub use num::{Primitive, Int, Float};
113
114 pub use ptr::Ptr;
115 pub use to_str::ToStr;
116 pub use clone::Clone;
117
118 // On Linux, link to the runtime with -lrt.
119 #[cfg(target_os = "linux")]
120 #[doc(hidden)]
121 pub mod linkhack {
122     #[link_args="-lrustrt -lrt"]
123     #[link_args = "-lpthread"]
124     extern {
125     }
126 }
127
128 // Internal macros
129 mod macros;
130
131 /* The Prelude. */
132
133 pub mod prelude;
134
135 /* Primitive types */
136
137 #[path = "num/int-template.rs"] #[merge = "num/int-template/int.rs"]
138 pub mod int;
139 #[path = "num/int-template.rs"] #[merge = "num/int-template/i8.rs"]
140 pub mod i8;
141 #[path = "num/int-template.rs"] #[merge = "num/int-template/i16.rs"]
142 pub mod i16;
143 #[path = "num/int-template.rs"] #[merge = "num/int-template/i32.rs"]
144 pub mod i32;
145 #[path = "num/int-template.rs"] #[merge = "num/int-template/i64.rs"]
146 pub mod i64;
147 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/uint.rs"]
148 pub mod uint;
149
150 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/u8.rs"]
151 pub mod u8;
152 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/u16.rs"]
153 pub mod u16;
154 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/u32.rs"]
155 pub mod u32;
156 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/u64.rs"]
157 pub mod u64;
158
159 #[path = "num/float.rs"]
160 pub mod float;
161 #[path = "num/f32.rs"]
162 pub mod f32;
163 #[path = "num/f64.rs"]
164 pub mod f64;
165
166 pub mod nil;
167 pub mod bool;
168 pub mod char;
169 pub mod tuple;
170
171 pub mod vec;
172 pub mod at_vec;
173 pub mod str;
174
175 #[path = "str/ascii.rs"]
176 pub mod ascii;
177
178 pub mod ptr;
179 pub mod owned;
180 pub mod managed;
181
182
183 /* Core language traits */
184
185 #[cfg(notest)] pub mod kinds;
186 #[cfg(notest)] pub mod ops;
187 #[cfg(notest)] pub mod cmp;
188
189
190 /* Common traits */
191
192 pub mod from_str;
193 #[path = "num/num.rs"]
194 pub mod num;
195 pub mod iter;
196 pub mod old_iter;
197 pub mod iterator;
198 pub mod to_str;
199 pub mod to_bytes;
200 pub mod clone;
201 pub mod io;
202 pub mod hash;
203 pub mod container;
204
205
206 /* Common data structures */
207
208 pub mod option;
209 pub mod result;
210 pub mod either;
211 pub mod hashmap;
212 pub mod cell;
213 pub mod trie;
214
215
216 /* Tasks and communication */
217
218 #[path = "task/mod.rs"]
219 pub mod task;
220 pub mod comm;
221 pub mod pipes;
222
223
224 /* Runtime and platform support */
225
226 pub mod gc;
227 pub mod libc;
228 pub mod os;
229 pub mod path;
230 pub mod rand;
231 pub mod run;
232 pub mod sys;
233 pub mod cast;
234 pub mod flate;
235 pub mod repr;
236 pub mod cleanup;
237 pub mod reflect;
238 pub mod condition;
239 pub mod logging;
240 pub mod util;
241
242
243 /* Unsupported interfaces */
244
245 // Private APIs
246 pub mod unstable;
247
248 /* For internal use, not exported */
249
250 pub mod unicode;
251 #[path = "num/cmath.rs"]
252 pub mod cmath;
253 pub mod stackwalk;
254 #[path = "rt/mod.rs"]
255 pub mod rt;
256
257 // A curious inner-module that's not exported that contains the binding
258 // 'core' so that macro-expanded references to core::error and such
259 // can be resolved within libcore.
260 #[doc(hidden)]
261 mod core {
262     pub use clone;
263     pub use cmp;
264     pub use condition;
265     pub use option;
266     pub use kinds;
267     pub use sys;
268     pub use pipes;
269 }
270
271
272 // Local Variables:
273 // mode: rust;
274 // fill-column: 78;
275 // indent-tabs-mode: nil
276 // c-basic-offset: 4
277 // buffer-file-coding-system: utf-8-unix
278 // End: