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