(index<- ) ./libstd/lib.rs
git branch: * master 5200215 auto merge of #14035 : alexcrichton/rust/experimental, r=huonw
modified: Fri May 9 13:02:28 2014
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), [`mem`](mem/index.html),
20 //! and [`cast`](cast/index.html) modules deal with unsafe pointers,
21 //! memory manipulation, and coercion.
22 //! [`kinds`](kinds/index.html) defines the special built-in traits,
23 //! and [`raw`](raw/index.html) the runtime representation of Rust types.
24 //! These are some of the lowest-level building blocks of Rust
25 //! abstractions.
26 //!
27 //! ## Math on primitive types and math traits
28 //!
29 //! Although basic operations on primitive types are implemented
30 //! directly by the compiler, the standard library additionally
31 //! defines many common operations through traits defined in
32 //! mod [`num`](num/index.html).
33 //!
34 //! ## Pervasive types
35 //!
36 //! The [`option`](option/index.html) and [`result`](result/index.html)
37 //! modules define optional and error-handling types, `Option` and `Result`.
38 //! [`iter`](iter/index.html) defines Rust's iterator protocol
39 //! along with a wide variety of iterators.
40 //! [`Cell` and `RefCell`](cell/index.html) are for creating types that
41 //! manage their own mutability.
42 //!
43 //! ## Vectors, slices and strings
44 //!
45 //! The common container type, `Vec`, a growable vector backed by an
46 //! array, lives in the [`vec`](vec/index.html) module. References to
47 //! arrays, `&[T]`, more commonly called "slices", are built-in types
48 //! for which the [`slice`](slice/index.html) module defines many
49 //! methods.
50 //!
51 //! UTF-8 strings, `~str` and `&str`, are built-in types, and the
52 //! standard library defines methods for them on a variety of traits
53 //! in the [`str`](str/index.html) module. Rust strings are immutable;
54 //! use the `StrBuf` type defined in [`strbuf`](strbuf/index.html)
55 //! for a mutable string builder.
56 //!
57 //! For converting to strings use the [`format!`](fmt/index.html)
58 //! macro, and for converting from strings use the
59 //! [`FromStr`](from_str/index.html) trait.
60 //!
61 //! ## Platform abstractions
62 //!
63 //! Besides basic data types, the standard library is largely concerned
64 //! with abstracting over differences in common platforms, most notably
65 //! Windows and Unix derivatives. The [`os`](os/index.html) module
66 //! provides a number of basic functions for interacting with the
67 //! operating environment, including program arguments, environment
68 //! variables, and directory navigation. The [`path`](path/index.html)
69 //! module encapsulates the platform-specific rules for dealing
70 //! with file paths.
71 //!
72 //! `std` also includes modules for interoperating with the
73 //! C language: [`c_str`](c_str/index.html) and
74 //! [`c_vec`](c_vec/index.html).
75 //!
76 //! ## Concurrency, I/O, and the runtime
77 //!
78 //! The [`task`](task/index.html) module contains Rust's threading abstractions,
79 //! while [`comm`](comm/index.html) contains the channel types for message
80 //! passing. [`sync`](sync/index.html) contains further, primitive, shared
81 //! memory types, including [`atomics`](sync/atomics/index.html).
82 //!
83 //! Common types of I/O, including files, TCP, UPD, pipes, Unix domain sockets,
84 //! timers, and process spawning, are defined in the [`io`](io/index.html) module.
85 //!
86 //! Rust's I/O and concurrency depends on a small runtime interface
87 //! that lives, along with its support code, in mod [`rt`](rt/index.html).
88 //! While a notable part of the standard library's architecture, this
89 //! module is not intended for public use.
90 //!
91 //! ## The Rust prelude and macros
92 //!
93 //! Finally, the [`prelude`](prelude/index.html) defines a
94 //! common set of traits, types, and functions that are made available
95 //! to all code by default. [`macros`](macros/index.html) contains
96 //! all the standard macros, such as `assert!`, `fail!`, `println!`,
97 //! and `format!`, also available to all Rust code.
98
99 #![crate_id = "std#0.11-pre"]
100 #![comment = "The Rust standard library"]
101 #![license = "MIT/ASL2"]
102 #![crate_type = "rlib"]
103 #![crate_type = "dylib"]
104 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
105 html_favicon_url = "http://www.rust-lang.org/favicon.ico",
106 html_root_url = "http://static.rust-lang.org/doc/master")]
107 #![feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args,
108 simd, linkage, default_type_params, phase, concat_idents, quad_precision_float)]
109
110 // Don't link to std. We are std.
111 #![no_std]
112
113 #![deny(missing_doc)]
114
115 // When testing libstd, bring in libuv as the I/O backend so tests can print
116 // things and all of the std::io tests have an I/O interface to run on top
117 // of
118 #[cfg(test)] extern crate rustuv;
119 #[cfg(test)] extern crate native;
120 #[cfg(test)] extern crate green;
121 #[cfg(test)] #[phase(syntax, link)] extern crate log;
122
123 // Make and rand accessible for benchmarking/testcases
124 #[cfg(test)] extern crate rand;
125
126 extern crate libc;
127 extern crate core;
128
129 // Make std testable by not duplicating lang items. See #2912
130 #[cfg(test)] extern crate realstd = "std";
131 #[cfg(test)] pub use kinds = realstd::kinds;
132 #[cfg(test)] pub use ops = realstd::ops;
133 #[cfg(test)] pub use cmp = realstd::cmp;
134 #[cfg(test)] pub use ty = realstd::ty;
135 #[cfg(test)] pub use owned = realstd::owned;
136
137 #[cfg(not(test))] pub use cmp = core::cmp;
138 #[cfg(not(test))] pub use kinds = core::kinds;
139 #[cfg(not(test))] pub use ops = core::ops;
140 #[cfg(not(test))] pub use owned = core::owned;
141 #[cfg(not(test))] pub use ty = core::ty;
142
143 pub use core::any;
144 pub use core::bool;
145 pub use core::cast;
146 pub use core::cell;
147 pub use core::char;
148 pub use core::clone;
149 pub use core::container;
150 pub use core::default;
151 pub use core::intrinsics;
152 pub use core::iter;
153 pub use core::mem;
154 pub use core::ptr;
155 pub use core::raw;
156 pub use core::tuple;
157
158 // Run tests with libgreen instead of libnative.
159 //
160 // FIXME: This egregiously hacks around starting the test runner in a different
161 // threading mode than the default by reaching into the auto-generated
162 // '__test' module.
163 #[cfg(test)] #[start]
164 fn start(argc: int, argv: **u8) -> int {
165 green::start(argc, argv, rustuv::event_loop, __test::main)
166 }
167
168 /* Exported macros */
169
170 pub mod macros;
171 pub mod bitflags;
172
173 mod rtdeps;
174
175 /* The Prelude. */
176
177 pub mod prelude;
178
179
180 /* Primitive types */
181
182 #[path = "num/float_macros.rs"] mod float_macros;
183 #[path = "num/int_macros.rs"] mod int_macros;
184 #[path = "num/uint_macros.rs"] mod uint_macros;
185
186 #[path = "num/int.rs"] pub mod int;
187 #[path = "num/i8.rs"] pub mod i8;
188 #[path = "num/i16.rs"] pub mod i16;
189 #[path = "num/i32.rs"] pub mod i32;
190 #[path = "num/i64.rs"] pub mod i64;
191
192 #[path = "num/uint.rs"] pub mod uint;
193 #[path = "num/u8.rs"] pub mod u8;
194 #[path = "num/u16.rs"] pub mod u16;
195 #[path = "num/u32.rs"] pub mod u32;
196 #[path = "num/u64.rs"] pub mod u64;
197
198 #[path = "num/f32.rs"] pub mod f32;
199 #[path = "num/f64.rs"] pub mod f64;
200
201 pub mod slice;
202 pub mod vec;
203 pub mod str;
204 pub mod strbuf;
205
206 pub mod ascii;
207
208 pub mod rc;
209 pub mod gc;
210
211 /* Common traits */
212
213 pub mod from_str;
214 pub mod num;
215 pub mod to_str;
216 pub mod hash;
217
218 /* Common data structures */
219
220 pub mod result;
221 pub mod option;
222
223 /* Tasks and communication */
224
225 pub mod task;
226 pub mod comm;
227 pub mod local_data;
228 pub mod sync;
229
230
231 /* Runtime and platform support */
232
233 pub mod c_str;
234 pub mod c_vec;
235 pub mod os;
236 pub mod io;
237 pub mod path;
238 pub mod fmt;
239 pub mod cleanup;
240
241 /* Unsupported interfaces */
242
243 #[unstable]
244 pub mod repr;
245 #[unstable]
246 pub mod reflect;
247
248 // Private APIs
249 #[unstable]
250 pub mod unstable;
251
252 /* For internal use, not exported */
253
254 mod unicode;
255
256 // FIXME #7809: This shouldn't be pub, and it should be reexported under 'unstable'
257 // but name resolution doesn't work without it being pub.
258 #[unstable]
259 pub mod rt;
260
261 // A curious inner-module that's not exported that contains the binding
262 // 'std' so that macro-expanded references to std::error and such
263 // can be resolved within libstd.
264 #[doc(hidden)]
265 mod std {
266 pub use clone;
267 pub use cmp;
268 pub use comm;
269 pub use fmt;
270 pub use hash;
271 pub use io;
272 pub use kinds;
273 pub use local_data;
274 pub use option;
275 pub use os;
276 pub use rt;
277 pub use str;
278 pub use to_str;
279 pub use ty;
280 pub use unstable;
281 pub use vec;
282
283 // The test runner requires std::slice::Vector, so re-export std::slice just for it.
284 #[cfg(test)] pub use slice;
285 }