]> git.lizzy.rs Git - rust.git/blob - src/libstd/lib.rs
auto merge of #10685 : ebiggers/rust/ascii_fixes, r=alexcrichton
[rust.git] / src / libstd / lib.rs
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 //! # The Rust standard library
12 //!
13 //! The Rust standard library is a group of interrelated modules defining
14 //! the core language traits, operations on built-in data types, collections,
15 //! platform abstractions, the task scheduler, runtime support for language
16 //! features and other common functionality.
17 //!
18 //! `std` includes modules corresponding to each of the integer types,
19 //! each of the floating point types, the `bool` type, tuples, characters,
20 //! strings (`str`), vectors (`vec`), managed boxes (`managed`), owned
21 //! boxes (`owned`), and unsafe and borrowed pointers (`ptr`, `borrowed`).
22 //! Additionally, `std` provides pervasive types (`option` and `result`),
23 //! task creation and communication primitives (`task`, `comm`), platform
24 //! abstractions (`os` and `path`), basic I/O abstractions (`io`), common
25 //! traits (`kinds`, `ops`, `cmp`, `num`, `to_str`), and complete bindings
26 //! to the C standard library (`libc`).
27 //!
28 //! # Standard library injection and the Rust prelude
29 //!
30 //! `std` is imported at the topmost level of every crate by default, as
31 //! if the first line of each crate was
32 //!
33 //!     extern mod std;
34 //!
35 //! This means that the contents of std can be accessed from any context
36 //! with the `std::` path prefix, as in `use std::vec`, `use std::task::spawn`,
37 //! etc.
38 //!
39 //! Additionally, `std` contains a `prelude` module that reexports many of the
40 //! most common types, traits and functions. The contents of the prelude are
41 //! imported into every *module* by default.  Implicitly, all modules behave as if
42 //! they contained the following prologue:
43 //!
44 //!     use std::prelude::*;
45
46 #[link(name = "std",
47        package_id = "std",
48        vers = "0.9-pre",
49        uuid = "c70c24a7-5551-4f73-8e37-380b11d80be8",
50        url = "https://github.com/mozilla/rust/tree/master/src/libstd")];
51
52 #[comment = "The Rust standard library"];
53 #[license = "MIT/ASL2"];
54 #[crate_type = "lib"];
55
56 #[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
57       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
58       html_root_url = "http://static.rust-lang.org/doc/master")];
59
60 #[feature(macro_rules, globs, asm, managed_boxes)];
61
62 // Don't link to std. We are std.
63 #[no_std];
64
65 #[deny(non_camel_case_types)];
66 #[deny(missing_doc)];
67 #[allow(unrecognized_lint)]; // NOTE: remove after the next snapshot
68 #[allow(cstack)]; // NOTE: remove after the next snapshot.
69
70 // When testing libstd, bring in libuv as the I/O backend so tests can print
71 // things and all of the std::io tests have an I/O interface to run on top
72 // of
73 #[cfg(test)] extern mod rustuv(vers = "0.9-pre");
74
75 // Make extra accessible for benchmarking
76 #[cfg(test)] extern mod extra(vers = "0.9-pre");
77
78 // Make std testable by not duplicating lang items. See #2912
79 #[cfg(test)] extern mod realstd(name = "std");
80 #[cfg(test)] pub use kinds = realstd::kinds;
81 #[cfg(test)] pub use ops = realstd::ops;
82 #[cfg(test)] pub use cmp = realstd::cmp;
83
84 // On Linux, link to the runtime with -lrt.
85 #[cfg(target_os = "linux")]
86 #[doc(hidden)]
87 pub mod linkhack {
88     #[link_args="-lrustrt -lrt"]
89     #[link_args = "-lpthread"]
90     extern {
91     }
92 }
93
94 /* The Prelude. */
95
96 pub mod prelude;
97
98
99 /* Primitive types */
100
101 #[path = "num/int_macros.rs"]   mod int_macros;
102 #[path = "num/uint_macros.rs"]  mod uint_macros;
103
104 #[path = "num/int.rs"]  pub mod int;
105 #[path = "num/i8.rs"]   pub mod i8;
106 #[path = "num/i16.rs"]  pub mod i16;
107 #[path = "num/i32.rs"]  pub mod i32;
108 #[path = "num/i64.rs"]  pub mod i64;
109
110 #[path = "num/uint.rs"] pub mod uint;
111 #[path = "num/u8.rs"]   pub mod u8;
112 #[path = "num/u16.rs"]  pub mod u16;
113 #[path = "num/u32.rs"]  pub mod u32;
114 #[path = "num/u64.rs"]  pub mod u64;
115
116 #[path = "num/f32.rs"]   pub mod f32;
117 #[path = "num/f64.rs"]   pub mod f64;
118
119 pub mod unit;
120 pub mod bool;
121 pub mod char;
122 pub mod tuple;
123
124 pub mod vec;
125 pub mod at_vec;
126 pub mod str;
127
128 pub mod ascii;
129 pub mod send_str;
130
131 pub mod ptr;
132 pub mod owned;
133 pub mod managed;
134 pub mod borrow;
135 pub mod rc;
136 pub mod gc;
137
138
139 /* Core language traits */
140
141 #[cfg(not(test))] pub mod kinds;
142 #[cfg(not(test))] pub mod ops;
143 #[cfg(not(test))] pub mod cmp;
144
145
146 /* Common traits */
147
148 pub mod from_str;
149 pub mod num;
150 pub mod iter;
151 pub mod to_str;
152 pub mod to_bytes;
153 pub mod clone;
154 pub mod hash;
155 pub mod container;
156 pub mod default;
157 pub mod any;
158
159
160 /* Common data structures */
161
162 pub mod option;
163 pub mod result;
164 pub mod either;
165 pub mod hashmap;
166 pub mod cell;
167 pub mod trie;
168
169
170 /* Tasks and communication */
171
172 pub mod task;
173 pub mod comm;
174 pub mod select;
175 pub mod local_data;
176
177
178 /* Runtime and platform support */
179
180 pub mod libc;
181 pub mod c_str;
182 pub mod os;
183 pub mod io;
184 pub mod path;
185 pub mod rand;
186 pub mod run;
187 pub mod cast;
188 pub mod fmt;
189 pub mod repr;
190 pub mod cleanup;
191 pub mod reflect;
192 pub mod condition;
193 pub mod logging;
194 pub mod util;
195 pub mod mem;
196
197
198 /* Unsupported interfaces */
199
200 // Private APIs
201 pub mod unstable;
202
203
204 /* For internal use, not exported */
205
206 mod unicode;
207 #[path = "num/cmath.rs"]
208 mod cmath;
209
210 // FIXME #7809: This shouldn't be pub, and it should be reexported under 'unstable'
211 // but name resolution doesn't work without it being pub.
212 pub mod rt;
213
214 // A curious inner-module that's not exported that contains the binding
215 // 'std' so that macro-expanded references to std::error and such
216 // can be resolved within libstd.
217 #[doc(hidden)]
218 mod std {
219     pub use clone;
220     pub use cmp;
221     pub use condition;
222     pub use fmt;
223     pub use kinds;
224     pub use local_data;
225     pub use logging;
226     pub use logging;
227     pub use option;
228     pub use os;
229     pub use io;
230     pub use rt;
231     pub use str;
232     pub use to_bytes;
233     pub use to_str;
234     pub use unstable;
235 }