]> git.lizzy.rs Git - rust.git/blob - src/libstd/lib.rs
fallout: part of changes to compile-fail tests. (follows same pattern as prior two...
[rust.git] / src / libstd / lib.rs
1 // Copyright 2012-2014 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 provides the essential runtime
14 //! functionality for building portable Rust software.
15 //! It is linked to all Rust crates by default.
16 //!
17 //! ## Intrinsic types and operations
18 //!
19 //! The [`ptr`](ptr/index.html) and [`mem`](mem/index.html)
20 //! modules deal with unsafe pointers and memory manipulation.
21 //! [`markers`](markers/index.html) defines the special built-in traits,
22 //! and [`raw`](raw/index.html) the runtime representation of Rust types.
23 //! These are some of the lowest-level building blocks in Rust.
24 //!
25 //! ## Math on primitive types and math traits
26 //!
27 //! Although basic operations on primitive types are implemented
28 //! directly by the compiler, the standard library additionally
29 //! defines many common operations through traits defined in
30 //! mod [`num`](num/index.html).
31 //!
32 //! ## Pervasive types
33 //!
34 //! The [`option`](option/index.html) and [`result`](result/index.html)
35 //! modules define optional and error-handling types, `Option` and `Result`.
36 //! [`iter`](iter/index.html) defines Rust's iterator protocol
37 //! along with a wide variety of iterators.
38 //! [`Cell` and `RefCell`](cell/index.html) are for creating types that
39 //! manage their own mutability.
40 //!
41 //! ## Vectors, slices and strings
42 //!
43 //! The common container type, `Vec`, a growable vector backed by an
44 //! array, lives in the [`vec`](vec/index.html) module. References to
45 //! arrays, `&[T]`, more commonly called "slices", are built-in types
46 //! for which the [`slice`](slice/index.html) module defines many
47 //! methods.
48 //!
49 //! `&str`, a UTF-8 string, is a built-in type, and the standard library
50 //! defines methods for it on a variety of traits in the
51 //! [`str`](str/index.html) module. Rust strings are immutable;
52 //! use the `String` type defined in [`string`](string/index.html)
53 //! for a mutable string builder.
54 //!
55 //! For converting to strings use the [`format!`](fmt/index.html)
56 //! macro, and for converting from strings use the
57 //! [`FromStr`](str/trait.FromStr.html) trait.
58 //!
59 //! ## Platform abstractions
60 //!
61 //! Besides basic data types, the standard library is largely concerned
62 //! with abstracting over differences in common platforms, most notably
63 //! Windows and Unix derivatives. The [`os`](os/index.html) module
64 //! provides a number of basic functions for interacting with the
65 //! operating environment, including program arguments, environment
66 //! variables, and directory navigation. The [`path`](path/index.html)
67 //! module encapsulates the platform-specific rules for dealing
68 //! with file paths.
69 //!
70 //! `std` also includes modules for interoperating with the
71 //! C language: [`c_str`](c_str/index.html) and
72 //! [`c_vec`](c_vec/index.html).
73 //!
74 //! ## Concurrency, I/O, and the runtime
75 //!
76 //! The [`task`](task/index.html) module contains Rust's threading abstractions,
77 //! while [`comm`](comm/index.html) contains the channel types for message
78 //! passing. [`sync`](sync/index.html) contains further, primitive, shared
79 //! memory types, including [`atomic`](sync/atomic/index.html).
80 //!
81 //! Common types of I/O, including files, TCP, UDP, pipes, Unix domain sockets,
82 //! timers, and process spawning, are defined in the [`io`](io/index.html) module.
83 //!
84 //! Rust's I/O and concurrency depends on a small runtime interface
85 //! that lives, along with its support code, in mod [`rt`](rt/index.html).
86 //! While a notable part of the standard library's architecture, this
87 //! module is not intended for public use.
88 //!
89 //! ## The Rust prelude and macros
90 //!
91 //! Finally, the [`prelude`](prelude/index.html) defines a
92 //! common set of traits, types, and functions that are made available
93 //! to all code by default. [`macros`](macros/index.html) contains
94 //! all the standard macros, such as `assert!`, `panic!`, `println!`,
95 //! and `format!`, also available to all Rust code.
96
97 #![crate_name = "std"]
98 #![stable]
99 #![crate_type = "rlib"]
100 #![crate_type = "dylib"]
101 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
102        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
103        html_root_url = "http://doc.rust-lang.org/nightly/",
104        html_playground_url = "http://play.rust-lang.org/")]
105
106 #![allow(unknown_features)]
107 #![feature(linkage, thread_local, asm)]
108 #![feature(lang_items, unsafe_destructor)]
109 #![feature(slicing_syntax, unboxed_closures)]
110 #![feature(box_syntax)]
111 #![feature(old_impl_check)]
112 #![cfg_attr(stage0, allow(unused_attributes))]
113
114 // Don't link to std. We are std.
115 #![no_std]
116
117 #![deny(missing_docs)]
118
119 #[cfg(test)]
120 #[macro_use]
121 extern crate log;
122
123 #[macro_use]
124 #[macro_reexport(assert, assert_eq, debug_assert, debug_assert_eq,
125                  unreachable, unimplemented, write, writeln)]
126 extern crate core;
127
128 #[macro_use]
129 #[macro_reexport(vec)]
130 extern crate "collections" as core_collections;
131
132 extern crate "rand" as core_rand;
133 extern crate alloc;
134 extern crate unicode;
135 extern crate libc;
136
137 // Make std testable by not duplicating lang items. See #2912
138 #[cfg(test)] extern crate "std" as realstd;
139 #[cfg(test)] pub use realstd::marker;
140 #[cfg(test)] pub use realstd::ops;
141 #[cfg(test)] pub use realstd::cmp;
142 #[cfg(test)] pub use realstd::boxed;
143
144
145 // NB: These reexports are in the order they should be listed in rustdoc
146
147 pub use core::any;
148 pub use core::borrow;
149 pub use core::cell;
150 pub use core::clone;
151 #[cfg(not(test))] pub use core::cmp;
152 pub use core::default;
153 pub use core::finally;
154 pub use core::intrinsics;
155 pub use core::iter;
156 #[cfg(stage0)] #[cfg(not(test))] pub use core::marker as kinds;
157 #[cfg(not(test))] pub use core::marker;
158 pub use core::mem;
159 #[cfg(not(test))] pub use core::ops;
160 pub use core::ptr;
161 pub use core::raw;
162 pub use core::simd;
163 pub use core::result;
164 pub use core::option;
165
166 #[cfg(not(test))] pub use alloc::boxed;
167 pub use alloc::rc;
168
169 pub use core_collections::slice;
170 pub use core_collections::str;
171 pub use core_collections::string;
172 #[stable]
173 pub use core_collections::vec;
174
175 pub use unicode::char;
176
177 /* Exported macros */
178
179 #[macro_use]
180 pub mod macros;
181
182 #[macro_use]
183 pub mod bitflags;
184
185 mod rtdeps;
186
187 /* The Prelude. */
188
189 pub mod prelude;
190
191
192 /* Primitive types */
193
194 #[path = "num/float_macros.rs"]
195 #[macro_use]
196 mod float_macros;
197
198 #[path = "num/int_macros.rs"]
199 #[macro_use]
200 mod int_macros;
201
202 #[path = "num/uint_macros.rs"]
203 #[macro_use]
204 mod uint_macros;
205
206 #[path = "num/int.rs"]  pub mod int;
207 #[path = "num/i8.rs"]   pub mod i8;
208 #[path = "num/i16.rs"]  pub mod i16;
209 #[path = "num/i32.rs"]  pub mod i32;
210 #[path = "num/i64.rs"]  pub mod i64;
211
212 #[path = "num/uint.rs"] pub mod uint;
213 #[path = "num/u8.rs"]   pub mod u8;
214 #[path = "num/u16.rs"]  pub mod u16;
215 #[path = "num/u32.rs"]  pub mod u32;
216 #[path = "num/u64.rs"]  pub mod u64;
217
218 #[path = "num/f32.rs"]   pub mod f32;
219 #[path = "num/f64.rs"]   pub mod f64;
220
221 pub mod ascii;
222 pub mod thunk;
223
224 /* Common traits */
225
226 pub mod error;
227 pub mod num;
228
229 /* Runtime and platform support */
230
231 #[macro_use]
232 pub mod thread_local;
233
234 pub mod dynamic_lib;
235 pub mod ffi;
236 pub mod fmt;
237 pub mod io;
238 pub mod os;
239 pub mod path;
240 pub mod rand;
241 pub mod time;
242
243 /* Common data structures */
244
245 pub mod collections;
246 pub mod hash;
247
248 /* Threads and communication */
249
250 pub mod thread;
251 pub mod sync;
252
253 #[cfg(unix)]
254 #[path = "sys/unix/mod.rs"] mod sys;
255 #[cfg(windows)]
256 #[path = "sys/windows/mod.rs"] mod sys;
257
258 #[path = "sys/common/mod.rs"] mod sys_common;
259
260 pub mod rt;
261 mod failure;
262
263 // Documentation for primitive types
264
265 mod bool;
266 mod unit;
267 mod tuple;
268
269 // A curious inner-module that's not exported that contains the binding
270 // 'std' so that macro-expanded references to std::error and such
271 // can be resolved within libstd.
272 #[doc(hidden)]
273 mod std {
274     // mods used for deriving
275     pub use clone;
276     pub use cmp;
277     pub use hash;
278
279     pub use sync; // used for select!()
280     pub use error; // used for try!()
281     pub use fmt; // used for any formatting strings
282     pub use io; // used for println!()
283     pub use option; // used for bitflags!{}
284     pub use rt; // used for panic!()
285     pub use vec; // used for vec![]
286     pub use cell; // used for tls!
287     pub use thread_local; // used for thread_local!
288     #[cfg(stage0)]
289     pub use marker as kinds;
290     pub use marker;  // used for tls!
291     pub use ops; // used for bitflags!
292
293     // The test runner calls ::std::os::args() but really wants realstd
294     #[cfg(test)] pub use realstd::os as os;
295     // The test runner requires std::slice::Vector, so re-export std::slice just for it.
296     //
297     // It is also used in vec![]
298     pub use slice;
299
300     pub use boxed; // used for vec![]
301
302 }