]> git.lizzy.rs Git - rust.git/blob - src/libstd/lib.rs
std: Rewrite crate docs
[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), [`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).
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 set of
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
98 #![crate_id = "std#0.11-pre"]
99 #![comment = "The Rust standard library"]
100 #![license = "MIT/ASL2"]
101 #![crate_type = "rlib"]
102 #![crate_type = "dylib"]
103 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
104        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
105        html_root_url = "http://static.rust-lang.org/doc/master")]
106 #![feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args,
107            simd, linkage, default_type_params, phase, concat_idents)]
108
109 // Don't link to std. We are std.
110 #![no_std]
111
112 #![deny(missing_doc)]
113
114 // When testing libstd, bring in libuv as the I/O backend so tests can print
115 // things and all of the std::io tests have an I/O interface to run on top
116 // of
117 #[cfg(test)] extern crate rustuv;
118 #[cfg(test)] extern crate native;
119 #[cfg(test)] extern crate green;
120 #[cfg(test)] #[phase(syntax, link)] extern crate log;
121
122 // Make and rand accessible for benchmarking/testcases
123 #[cfg(test)] extern crate rand;
124
125 // we wrap some libc stuff
126 extern crate libc;
127
128 // Make std testable by not duplicating lang items. See #2912
129 #[cfg(test)] extern crate realstd = "std";
130 #[cfg(test)] pub use kinds = realstd::kinds;
131 #[cfg(test)] pub use ops = realstd::ops;
132 #[cfg(test)] pub use cmp = realstd::cmp;
133 #[cfg(test)] pub use ty = realstd::ty;
134
135 // Run tests with libgreen instead of libnative.
136 //
137 // FIXME: This egregiously hacks around starting the test runner in a different
138 //        threading mode than the default by reaching into the auto-generated
139 //        '__test' module.
140 #[cfg(test)] #[start]
141 fn start(argc: int, argv: **u8) -> int {
142     green::start(argc, argv, rustuv::event_loop, __test::main)
143 }
144
145 pub mod macros;
146
147 mod rtdeps;
148
149 /* The Prelude. */
150
151 pub mod prelude;
152
153
154 /* Primitive types */
155
156 #[path = "num/float_macros.rs"] mod float_macros;
157 #[path = "num/int_macros.rs"]   mod int_macros;
158 #[path = "num/uint_macros.rs"]  mod uint_macros;
159
160 #[path = "num/int.rs"]  pub mod int;
161 #[path = "num/i8.rs"]   pub mod i8;
162 #[path = "num/i16.rs"]  pub mod i16;
163 #[path = "num/i32.rs"]  pub mod i32;
164 #[path = "num/i64.rs"]  pub mod i64;
165
166 #[path = "num/uint.rs"] pub mod uint;
167 #[path = "num/u8.rs"]   pub mod u8;
168 #[path = "num/u16.rs"]  pub mod u16;
169 #[path = "num/u32.rs"]  pub mod u32;
170 #[path = "num/u64.rs"]  pub mod u64;
171
172 #[path = "num/f32.rs"]   pub mod f32;
173 #[path = "num/f64.rs"]   pub mod f64;
174
175 pub mod unit;
176 pub mod bool;
177 pub mod char;
178 pub mod tuple;
179
180 pub mod slice;
181 pub mod vec;
182 pub mod str;
183 pub mod strbuf;
184
185 pub mod ascii;
186
187 pub mod ptr;
188 pub mod owned;
189 mod managed;
190 mod reference;
191 pub mod rc;
192 pub mod gc;
193
194
195 /* Core language traits */
196
197 #[cfg(not(test))] pub mod kinds;
198 #[cfg(not(test))] pub mod ops;
199 #[cfg(not(test))] pub mod cmp;
200 #[cfg(not(test))] pub mod ty;
201
202
203 /* Common traits */
204
205 pub mod from_str;
206 pub mod num;
207 pub mod iter;
208 pub mod to_str;
209 pub mod clone;
210 pub mod hash;
211 pub mod container;
212 pub mod default;
213 pub mod any;
214
215 /* Common data structures */
216
217 pub mod option;
218 pub mod result;
219 pub mod cell;
220
221
222 /* Tasks and communication */
223
224 pub mod task;
225 pub mod comm;
226 pub mod local_data;
227 pub mod sync;
228
229
230 /* Runtime and platform support */
231
232 pub mod c_str;
233 pub mod c_vec;
234 pub mod os;
235 pub mod io;
236 pub mod path;
237 pub mod cast;
238 pub mod fmt;
239 pub mod cleanup;
240 pub mod mem;
241
242
243 /* Unsupported interfaces */
244
245 #[unstable]
246 pub mod repr;
247 #[unstable]
248 pub mod reflect;
249
250 // Private APIs
251 #[unstable]
252 pub mod unstable;
253 #[experimental]
254 pub mod intrinsics;
255 #[experimental]
256 pub mod raw;
257
258 /* For internal use, not exported */
259
260 mod unicode;
261
262 // FIXME #7809: This shouldn't be pub, and it should be reexported under 'unstable'
263 // but name resolution doesn't work without it being pub.
264 #[unstable]
265 pub mod rt;
266
267 // A curious inner-module that's not exported that contains the binding
268 // 'std' so that macro-expanded references to std::error and such
269 // can be resolved within libstd.
270 #[doc(hidden)]
271 mod std {
272     pub use clone;
273     pub use cmp;
274     pub use comm;
275     pub use fmt;
276     pub use hash;
277     pub use io;
278     pub use kinds;
279     pub use local_data;
280     pub use option;
281     pub use os;
282     pub use rt;
283     pub use str;
284     pub use to_str;
285     pub use ty;
286     pub use unstable;
287     pub use vec;
288 }