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.
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.
13 # The Rust core library
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
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`).
29 # Core injection and the Rust prelude
31 `core` is imported at the topmost level of every crate by default, as
32 if the first line of each crate was
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`,
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:
52 uuid = "c70c24a7-5551-4f73-8e37-380b11d80be8",
53 url = "https://github.com/mozilla/rust/tree/master/src/libcore")];
55 #[comment = "The Rust core library"];
56 #[license = "MIT/ASL2"];
57 #[crate_type = "lib"];
60 // Don't link to core. We are core.
63 #[warn(vecs_implicitly_copyable)];
64 #[deny(non_camel_case_types)];
65 #[allow(deprecated_mutable_fields)];
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;
73 /* Reexported core operators */
75 pub use kinds::{Const, Copy, Owned, Durable};
78 pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not};
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};
85 /* Reexported types and traits */
87 pub use option::{Option, Some, None};
88 pub use result::{Result, Ok, Err};
91 pub use path::GenericPath;
92 pub use path::WindowsPath;
93 pub use path::PosixPath;
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};
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};
114 pub use to_str::ToStr;
115 pub use clone::Clone;
117 // On Linux, link to the runtime with -lrt.
118 #[cfg(target_os = "linux")]
121 #[link_args="-lrustrt -lrt"]
122 #[link_args = "-lpthread"]
131 /* Primitive types */
133 #[path = "num/int-template.rs"] #[merge = "num/int-template/int.rs"]
135 #[path = "num/int-template.rs"] #[merge = "num/int-template/i8.rs"]
137 #[path = "num/int-template.rs"] #[merge = "num/int-template/i16.rs"]
139 #[path = "num/int-template.rs"] #[merge = "num/int-template/i32.rs"]
141 #[path = "num/int-template.rs"] #[merge = "num/int-template/i64.rs"]
143 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/uint.rs"]
146 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/u8.rs"]
148 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/u16.rs"]
150 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/u32.rs"]
152 #[path = "num/uint-template.rs"] #[merge = "num/uint-template/u64.rs"]
155 #[path = "num/float.rs"]
157 #[path = "num/f32.rs"]
159 #[path = "num/f64.rs"]
171 #[path = "str/ascii.rs"]
179 /* Core language traits */
181 #[cfg(notest)] pub mod kinds;
182 #[cfg(notest)] pub mod ops;
183 #[cfg(notest)] pub mod cmp;
189 #[path = "num/num.rs"]
202 /* Common data structures */
212 /* Tasks and communication */
214 #[path = "task/mod.rs"]
220 /* Runtime and platform support */
239 /* Unsupported interfaces */
244 /* For internal use, not exported */
247 #[path = "num/cmath.rs"]
250 #[path = "rt/mod.rs"]
253 // A curious inner-module that's not exported that contains the binding
254 // 'core' so that macro-expanded references to core::error and such
255 // can be resolved within libcore.