]> git.lizzy.rs Git - rust.git/blob - src/libstd/lib.rs
rand: Use fill() instead of read()
[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 is a group of interrelated modules defining
14 //! the core language traits, operations on built-in data types,
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 pointers and references (`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 crate 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 #[crate_id = "std#0.10-pre"];
47 #[comment = "The Rust standard library"];
48 #[license = "MIT/ASL2"];
49 #[crate_type = "rlib"];
50 #[crate_type = "dylib"];
51 #[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
52       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
53       html_root_url = "http://static.rust-lang.org/doc/master")];
54 #[feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args,
55           simd, linkage, default_type_params, phase)];
56
57 // Don't link to std. We are std.
58 #[no_std];
59
60 #[deny(missing_doc)];
61 #[allow(deprecated_owned_vector)]; // NOTE: remove after stage0
62
63 // When testing libstd, bring in libuv as the I/O backend so tests can print
64 // things and all of the std::io tests have an I/O interface to run on top
65 // of
66 #[cfg(test)] extern crate rustuv;
67 #[cfg(test)] extern crate native;
68 #[cfg(test)] extern crate green;
69 #[cfg(test)] #[phase(syntax, link)] extern crate log;
70
71 // Make and rand accessible for benchmarking/testcases
72 #[cfg(test)] extern crate rand;
73
74 // Make std testable by not duplicating lang items. See #2912
75 #[cfg(test)] extern crate realstd = "std";
76 #[cfg(test)] pub use kinds = realstd::kinds;
77 #[cfg(test)] pub use ops = realstd::ops;
78 #[cfg(test)] pub use cmp = realstd::cmp;
79 #[cfg(test)] pub use ty = realstd::ty;
80
81 #[cfg(stage0)]
82 pub use vec_ng = vec;
83
84 // Run tests with libgreen instead of libnative.
85 //
86 // FIXME: This egregiously hacks around starting the test runner in a different
87 //        threading mode than the default by reaching into the auto-generated
88 //        '__test' module.
89 #[cfg(test)] #[start]
90 fn start(argc: int, argv: **u8) -> int {
91     green::start(argc, argv, __test::main)
92 }
93
94 pub mod macros;
95
96 mod rtdeps;
97
98 /* The Prelude. */
99
100 pub mod prelude;
101
102
103 /* Primitive types */
104
105 #[path = "num/float_macros.rs"] mod float_macros;
106 #[path = "num/int_macros.rs"]   mod int_macros;
107 #[path = "num/uint_macros.rs"]  mod uint_macros;
108
109 #[path = "num/int.rs"]  pub mod int;
110 #[path = "num/i8.rs"]   pub mod i8;
111 #[path = "num/i16.rs"]  pub mod i16;
112 #[path = "num/i32.rs"]  pub mod i32;
113 #[path = "num/i64.rs"]  pub mod i64;
114
115 #[path = "num/uint.rs"] pub mod uint;
116 #[path = "num/u8.rs"]   pub mod u8;
117 #[path = "num/u16.rs"]  pub mod u16;
118 #[path = "num/u32.rs"]  pub mod u32;
119 #[path = "num/u64.rs"]  pub mod u64;
120
121 #[path = "num/f32.rs"]   pub mod f32;
122 #[path = "num/f64.rs"]   pub mod f64;
123
124 pub mod unit;
125 pub mod bool;
126 pub mod char;
127 pub mod tuple;
128
129 pub mod slice;
130 pub mod vec;
131 pub mod str;
132
133 pub mod ascii;
134
135 pub mod ptr;
136 pub mod owned;
137 pub mod managed;
138 mod reference;
139 pub mod rc;
140 pub mod gc;
141
142
143 /* Core language traits */
144
145 #[cfg(not(test))] pub mod kinds;
146 #[cfg(not(test))] pub mod ops;
147 #[cfg(not(test))] pub mod cmp;
148 #[cfg(not(test))] pub mod ty;
149
150
151 /* Common traits */
152
153 pub mod from_str;
154 pub mod num;
155 pub mod iter;
156 pub mod to_str;
157 pub mod clone;
158 pub mod hash;
159 pub mod container;
160 pub mod default;
161 pub mod any;
162
163 /* Common data structures */
164
165 pub mod option;
166 pub mod result;
167 pub mod cell;
168
169
170 /* Tasks and communication */
171
172 pub mod task;
173 pub mod comm;
174 pub mod local_data;
175 pub mod sync;
176
177
178 /* Runtime and platform support */
179
180 #[unstable]
181 pub mod libc;
182 pub mod c_str;
183 pub mod c_vec;
184 pub mod os;
185 pub mod io;
186 pub mod path;
187 pub mod cast;
188 pub mod fmt;
189 pub mod cleanup;
190 pub mod mem;
191
192
193 /* Unsupported interfaces */
194
195 #[unstable]
196 pub mod repr;
197 #[unstable]
198 pub mod reflect;
199
200 // Private APIs
201 #[unstable]
202 pub mod unstable;
203 #[experimental]
204 pub mod intrinsics;
205 #[experimental]
206 pub mod raw;
207
208 /* For internal use, not exported */
209
210 mod unicode;
211 #[path = "num/cmath.rs"]
212 mod cmath;
213
214 // FIXME #7809: This shouldn't be pub, and it should be reexported under 'unstable'
215 // but name resolution doesn't work without it being pub.
216 #[unstable]
217 pub mod rt;
218
219 // A curious inner-module that's not exported that contains the binding
220 // 'std' so that macro-expanded references to std::error and such
221 // can be resolved within libstd.
222 #[doc(hidden)]
223 mod std {
224     pub use clone;
225     pub use cmp;
226     pub use comm;
227     pub use fmt;
228     pub use hash;
229     pub use io;
230     pub use kinds;
231     pub use local_data;
232     pub use option;
233     pub use os;
234     pub use rt;
235     pub use str;
236     pub use to_str;
237     pub use ty;
238     pub use unstable;
239 }