]> git.lizzy.rs Git - rust.git/blob - src/libcore/core.rc
libcore: Export core::from_str::FromStr from core::prelude
[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
67 // Make core testable by not duplicating lang items. See #2912
68 #[cfg(test)] extern mod realcore(name = "core", vers = "0.7-pre");
69 #[cfg(test)] pub use kinds = realcore::kinds;
70 #[cfg(test)] pub use ops = realcore::ops;
71 #[cfg(test)] pub use cmp = realcore::cmp;
72
73 /* Reexported core operators */
74
75 pub use kinds::{Const, Copy, Owned, Durable};
76 pub use ops::{Drop};
77 #[cfg(stage0)]
78 pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not};
79 #[cfg(not(stage0))]
80 pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
81 pub use ops::{BitAnd, BitOr, BitXor};
82 pub use ops::{Shl, Shr, Index};
83
84
85 /* Reexported types and traits */
86
87 pub use option::{Option, Some, None};
88 pub use result::{Result, Ok, Err};
89
90 pub use path::Path;
91 pub use path::GenericPath;
92 pub use path::WindowsPath;
93 pub use path::PosixPath;
94
95 pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
96 pub use str::{StrSlice};
97 pub use container::{Container, Mutable};
98 pub use vec::{CopyableVector, ImmutableVector};
99 pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
100 pub use vec::{OwnedVector, OwnedCopyableVector, MutableVector};
101 pub use old_iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
102 pub use old_iter::{CopyableOrderedIter, CopyableNonstrictIter};
103 pub use old_iter::{ExtendedMutableIter};
104 pub use iter::Times;
105
106 pub use num::{Num, NumCast};
107 pub use num::{Orderable, Signed, Unsigned, Round};
108 pub use num::{Algebraic, Trigonometric, Exponential, Hyperbolic};
109 pub use num::{Integer, Fractional, Real, RealExt};
110 pub use num::{Bitwise, BitCount, Bounded};
111 pub use num::{Primitive, Int, Float};
112
113 pub use ptr::Ptr;
114 pub use from_str::FromStr;
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 /* The Prelude. */
129
130 pub mod prelude;
131
132 /* Primitive types */
133
134 #[path = "num/int-template.rs"] #[merge = "num/int-template/int.rs"]
135 pub mod int;
136 #[path = "num/int-template.rs"] #[merge = "num/int-template/i8.rs"]
137 pub mod i8;
138 #[path = "num/int-template.rs"] #[merge = "num/int-template/i16.rs"]
139 pub mod i16;
140 #[path = "num/int-template.rs"] #[merge = "num/int-template/i32.rs"]
141 pub mod i32;
142 #[path = "num/int-template.rs"] #[merge = "num/int-template/i64.rs"]
143 pub mod i64;
144 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/uint.rs"]
145 pub mod uint;
146
147 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/u8.rs"]
148 pub mod u8;
149 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/u16.rs"]
150 pub mod u16;
151 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/u32.rs"]
152 pub mod u32;
153 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/u64.rs"]
154 pub mod u64;
155
156 #[path = "num/float.rs"]
157 pub mod float;
158 #[path = "num/f32.rs"]
159 pub mod f32;
160 #[path = "num/f64.rs"]
161 pub mod f64;
162
163 pub mod nil;
164 pub mod bool;
165 pub mod char;
166 pub mod tuple;
167
168 pub mod vec;
169 pub mod at_vec;
170 pub mod str;
171
172 #[path = "str/ascii.rs"]
173 pub mod ascii;
174
175 pub mod ptr;
176 pub mod owned;
177 pub mod managed;
178
179
180 /* Core language traits */
181
182 #[cfg(notest)] pub mod kinds;
183 #[cfg(notest)] pub mod ops;
184 #[cfg(notest)] pub mod cmp;
185
186
187 /* Common traits */
188
189 pub mod from_str;
190 #[path = "num/num.rs"]
191 pub mod num;
192 pub mod iter;
193 pub mod old_iter;
194 pub mod iterator;
195 pub mod to_str;
196 pub mod to_bytes;
197 pub mod clone;
198 pub mod io;
199 pub mod hash;
200 pub mod container;
201
202
203 /* Common data structures */
204
205 pub mod option;
206 pub mod result;
207 pub mod either;
208 pub mod hashmap;
209 pub mod cell;
210 pub mod trie;
211
212
213 /* Tasks and communication */
214
215 #[path = "task/mod.rs"]
216 pub mod task;
217 pub mod comm;
218 pub mod pipes;
219
220
221 /* Runtime and platform support */
222
223 pub mod gc;
224 pub mod libc;
225 pub mod os;
226 pub mod path;
227 pub mod rand;
228 pub mod run;
229 pub mod sys;
230 pub mod cast;
231 pub mod flate;
232 pub mod repr;
233 pub mod cleanup;
234 pub mod reflect;
235 pub mod condition;
236 pub mod logging;
237 pub mod util;
238
239
240 /* Unsupported interfaces */
241
242 // Private APIs
243 pub mod unstable;
244
245 /* For internal use, not exported */
246
247 pub mod unicode;
248 #[path = "num/cmath.rs"]
249 pub mod cmath;
250 pub mod stackwalk;
251 #[path = "rt/mod.rs"]
252 pub mod rt;
253
254 // A curious inner-module that's not exported that contains the binding
255 // 'core' so that macro-expanded references to core::error and such
256 // can be resolved within libcore.
257 #[doc(hidden)]
258 mod core {
259     pub use clone;
260     pub use cmp;
261     pub use condition;
262     pub use option;
263     pub use kinds;
264     pub use sys;
265     pub use pipes;
266 }