core.rc 6.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

11 12
/*!

13
The Rust core library
14 15 16 17 18 19 20 21

The Rust core library provides runtime features required by the language,
including the task scheduler and memory allocators, as well as library
support for Rust built-in types, platform abstractions, and other commonly
used features.

`core` includes modules corresponding to each of the integer types, each of
the floating point types, the `bool` type, tuples, characters, strings,
22 23 24 25 26 27
vectors (`vec`), managed boxes (`managed`), owned boxes (`owned`), and unsafe
and borrowed pointers (`ptr`).  Additionally, `core` provides task management
and creation (`task`), communication primitives (`comm` and `pipes`), an
efficient vector builder (`dvec`), platform abstractions (`os` and `path`),
basic I/O abstractions (`io`), common traits (`cmp`, `num`, `to_str`), and
complete bindings to the C standard library (`libc`).
28

B
Brian Anderson 已提交
29 30
`core` is linked to all crates by default and its contents imported.
Implicitly, all crates behave as if they included the following prologue:
31 32 33 34 35 36

    extern mod core;
    use core::*;

*/

37

38
#[link(name = "core",
G
Graydon Hoare 已提交
39
       vers = "0.5",
40
       uuid = "c70c24a7-5551-4f73-8e37-380b11d80be8",
41
       url = "https://github.com/mozilla/rust/tree/master/src/libcore")];
42 43

#[comment = "The Rust core library"];
44
#[license = "MIT"];
45
#[crate_type = "lib"];
46

47

B
Brian Anderson 已提交
48 49 50
// Don't link to core. We are core.
#[no_core];

51
#[warn(deprecated_mode)];
T
Tim Chevalier 已提交
52
#[warn(deprecated_pattern)];
53
#[warn(vecs_implicitly_copyable)];
54
#[deny(non_camel_case_types)];
55

56

57
/* Primitive types */
58

59 60 61
#[path = "int-template.rs"] #[merge = "int-template/int.rs"]
pub mod int;
#[path = "int-template.rs"] #[merge = "int-template/i8.rs"]
B
Brian Anderson 已提交
62
pub mod i8;
63
#[path = "int-template.rs"] #[merge = "int-template/i16.rs"]
B
Brian Anderson 已提交
64
pub mod i16;
65
#[path = "int-template.rs"] #[merge = "int-template/i32.rs"]
B
Brian Anderson 已提交
66
pub mod i32;
67
#[path = "int-template.rs"] #[merge = "int-template/i64.rs"]
B
Brian Anderson 已提交
68
pub mod i64;
69
#[path = "uint-template.rs"] #[merge = "uint-template/uint.rs"]
B
Brian Anderson 已提交
70
pub mod uint;
71

72
#[path = "uint-template.rs"] #[merge = "uint-template/u8.rs"]
B
Brian Anderson 已提交
73
pub mod u8;
74
#[path = "uint-template.rs"] #[merge = "uint-template/u16.rs"]
B
Brian Anderson 已提交
75
pub mod u16;
76
#[path = "uint-template.rs"] #[merge = "uint-template/u32.rs"]
B
Brian Anderson 已提交
77
pub mod u32;
78
#[path = "uint-template.rs"] #[merge = "uint-template/u64.rs"]
B
Brian Anderson 已提交
79
pub mod u64;
80

81 82 83
pub mod float;
pub mod f32;
pub mod f64;
84

85
pub mod nil;
86
pub mod bool;
87
pub mod char;
88
pub mod tuple;
89 90 91 92 93 94

pub mod vec;
pub mod at_vec;
pub mod str;

pub mod ptr;
95
pub mod managed;
T
Tim Chevalier 已提交
96
pub mod owned;
97 98


99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
/* Core language traits */

#[cfg(notest)] pub mod kinds;
#[cfg(notest)] pub mod ops;
#[cfg(notest)] pub mod cmp;

// Make core testable by not duplicating lang items. See #2912
#[cfg(test)] extern mod realcore(name = "core", vers = "0.5");
#[cfg(test)] pub use kinds = realcore::kinds;
#[cfg(test)] pub use ops = realcore::ops;
#[cfg(test)] pub use cmp = realcore::cmp;


/* Common traits */

pub mod from_str;
115 116 117 118
pub mod num;
pub mod iter;
pub mod to_str;
pub mod to_bytes;
B
Brian Anderson 已提交
119
pub mod clone;
120 121
pub mod io;
pub mod hash;
122 123


124 125 126 127 128 129 130
/* Common data structures */

pub mod option;
#[path="iter-trait.rs"] #[merge = "iter-trait/option.rs"]
pub mod option_iter;
pub mod result;
pub mod either;
131
pub mod dvec;
132
#[path="iter-trait.rs"] #[merge = "iter-trait/dvec.rs"]
B
Brian Anderson 已提交
133
pub mod dvec_iter;
134
pub mod dlist;
135
#[path="iter-trait.rs"] #[merge = "iter-trait/dlist.rs"]
B
Brian Anderson 已提交
136
pub mod dlist_iter;
137
pub mod send_map;
M
Marijn Haverbeke 已提交
138

139 140 141

/* Tasks and communication */

142
pub mod comm;
B
Brian Anderson 已提交
143
#[path = "task/mod.rs"]
B
Brian Anderson 已提交
144
pub mod task;
145
pub mod pipes;
M
Marijn Haverbeke 已提交
146

147 148

/* Runtime and platform support */
149

150 151 152 153 154 155 156 157 158 159 160 161 162
pub mod gc;
pub mod libc;
pub mod os;
pub mod path;
pub mod rand;
pub mod run;
pub mod sys;
pub mod cast;
pub mod mutable;
pub mod flate;
pub mod repr;
pub mod cleanup;
pub mod reflect;
163
pub mod condition;
164 165
pub mod logging;
pub mod util;
166

167

168
/* Reexported core operators */
169

B
Brian Anderson 已提交
170
pub use kinds::{Const, Copy, Send, Durable};
171 172 173 174
pub use ops::{Drop};
pub use ops::{Add, Sub, Mul, Div, Modulo, Neg};
pub use ops::{BitAnd, BitOr, BitXor};
pub use ops::{Shl, Shr, Index};
B
Brian Anderson 已提交
175

B
Brian Anderson 已提交
176

177
/* Reexported types and traits */
B
Brian Anderson 已提交
178

179
pub use option::{Option, Some, None};
B
Brian Anderson 已提交
180 181
pub use result::{Result, Ok, Err};

182 183 184 185
pub use path::Path;
pub use path::GenericPath;
pub use path::WindowsPath;
pub use path::PosixPath;
B
Brian Anderson 已提交
186 187 188 189 190 191 192 193

pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
pub use str::{StrSlice, Trimmable};
pub use vec::{ConstVector, CopyableVector, ImmutableVector};
pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
pub use vec::{MutableVector, MutableCopyableVector};
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
194

B
Brian Anderson 已提交
195 196 197
pub use num::Num;
pub use ptr::Ptr;
pub use to_str::ToStr;
198
pub use clone::Clone;
B
Brian Anderson 已提交
199

200 201 202 203 204 205

/*
 * Export the log levels as global constants. Higher levels mean
 * more-verbosity. Error is the bottom level, default logging level is
 * warn-and-below.
 */
B
Brian Anderson 已提交
206 207 208 209 210 211 212 213 214 215

/// The error log level
pub const error : u32 = 1_u32;
/// The warning log level
pub const warn : u32 = 2_u32;
/// The info log level
pub const info : u32 = 3_u32;
/// The debug log level
pub const debug : u32 = 4_u32;

216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233

/* Unsupported interfaces */

// The runtime interface used by the compiler
#[cfg(notest)] pub mod rt;
// The runtime and compiler interface to fmt!
pub mod extfmt;
// Private APIs
pub mod private;


/* For internal use, not exported */

mod unicode;
mod cmath;
mod stackwalk;


B
Brian Anderson 已提交
234 235 236 237 238 239 240 241 242 243 244
// A curious inner-module that's not exported that contains the binding
// 'core' so that macro-expanded references to core::error and such
// can be resolved within libcore.
#[doc(hidden)] // FIXME #3538
mod core {
    pub const error : u32 = 1_u32;
    pub const warn : u32 = 2_u32;
    pub const info : u32 = 3_u32;
    pub const debug : u32 = 4_u32;
}

245

B
Brian Anderson 已提交
246 247 248 249
// Similar to above. Some magic to make core testable.
#[cfg(test)]
mod std {
    extern mod std(vers = "0.5");
250
    pub use std::std::test;
B
Brian Anderson 已提交
251 252
}

253

254 255 256 257 258 259 260
// Local Variables:
// mode: rust;
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// End: