]> git.lizzy.rs Git - rust.git/blob - src/libstd/lib.rs
Edited comment for docs to show std::io is deleted and replaced by std::rt::io
[rust.git] / src / libstd / lib.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 //! # 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, collections,
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 and borrowed pointers (`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 (`rt::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 mod 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 #[link(name = "std",
47        vers = "0.9-pre",
48        uuid = "c70c24a7-5551-4f73-8e37-380b11d80be8",
49        url = "https://github.com/mozilla/rust/tree/master/src/libstd")];
50
51 #[comment = "The Rust standard library"];
52 #[license = "MIT/ASL2"];
53 #[crate_type = "lib"];
54
55 #[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
56       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
57       html_root_url = "http://static.rust-lang.org/doc/master")];
58
59 #[feature(macro_rules, globs, asm, managed_boxes)];
60
61 // Don't link to std. We are std.
62 #[no_std];
63
64 #[deny(non_camel_case_types)];
65 #[deny(missing_doc)];
66
67 // When testing libstd, bring in libuv as the I/O backend so tests can print
68 // things and all of the std::rt::io tests have an I/O interface to run on top
69 // of
70 #[cfg(test)] extern mod rustuv(vers = "0.9-pre");
71
72 // Make extra accessible for benchmarking
73 #[cfg(test)] extern mod extra(vers = "0.9-pre");
74
75 // Make std testable by not duplicating lang items. See #2912
76 #[cfg(test)] extern mod realstd(name = "std");
77 #[cfg(test)] pub use kinds = realstd::kinds;
78 #[cfg(test)] pub use ops = realstd::ops;
79 #[cfg(test)] pub use cmp = realstd::cmp;
80
81 // On Linux, link to the runtime with -lrt.
82 #[cfg(target_os = "linux")]
83 #[doc(hidden)]
84 pub mod linkhack {
85     #[link_args="-lrustrt -lrt"]
86     #[link_args = "-lpthread"]
87     extern {
88     }
89 }
90
91 /* The Prelude. */
92
93 pub mod prelude;
94
95
96 /* Primitive types */
97
98 #[path = "num/int_macros.rs"]   mod int_macros;
99 #[path = "num/uint_macros.rs"]  mod uint_macros;
100
101 #[path = "num/int.rs"]  pub mod int;
102 #[path = "num/i8.rs"]   pub mod i8;
103 #[path = "num/i16.rs"]  pub mod i16;
104 #[path = "num/i32.rs"]  pub mod i32;
105 #[path = "num/i64.rs"]  pub mod i64;
106
107 #[path = "num/uint.rs"] pub mod uint;
108 #[path = "num/u8.rs"]   pub mod u8;
109 #[path = "num/u16.rs"]  pub mod u16;
110 #[path = "num/u32.rs"]  pub mod u32;
111 #[path = "num/u64.rs"]  pub mod u64;
112
113 #[path = "num/f32.rs"]   pub mod f32;
114 #[path = "num/f64.rs"]   pub mod f64;
115
116 pub mod unit;
117 pub mod bool;
118 pub mod char;
119 pub mod tuple;
120
121 pub mod vec;
122 pub mod at_vec;
123 pub mod str;
124
125 pub mod ascii;
126 pub mod send_str;
127
128 pub mod ptr;
129 pub mod owned;
130 pub mod managed;
131 pub mod borrow;
132 pub mod rc;
133
134
135 /* Core language traits */
136
137 #[cfg(not(test))] pub mod kinds;
138 #[cfg(not(test))] pub mod ops;
139 #[cfg(not(test))] pub mod cmp;
140
141
142 /* Common traits */
143
144 pub mod from_str;
145 pub mod num;
146 pub mod iter;
147 pub mod to_str;
148 pub mod to_bytes;
149 pub mod clone;
150 pub mod hash;
151 pub mod container;
152 pub mod default;
153 pub mod any;
154
155
156 /* Common data structures */
157
158 pub mod option;
159 pub mod result;
160 pub mod either;
161 pub mod hashmap;
162 pub mod cell;
163 pub mod trie;
164
165
166 /* Tasks and communication */
167
168 pub mod task;
169 pub mod comm;
170 pub mod select;
171 pub mod local_data;
172
173
174 /* Runtime and platform support */
175
176 pub mod libc;
177 pub mod c_str;
178 pub mod os;
179 pub mod path;
180 pub mod rand;
181 pub mod run;
182 pub mod cast;
183 pub mod fmt;
184 pub mod repr;
185 pub mod cleanup;
186 pub mod reflect;
187 pub mod condition;
188 pub mod logging;
189 pub mod util;
190 pub mod routine;
191 pub mod mem;
192
193
194 /* Unsupported interfaces */
195
196 // Private APIs
197 pub mod unstable;
198
199
200 /* For internal use, not exported */
201
202 mod unicode;
203 #[path = "num/cmath.rs"]
204 mod cmath;
205
206 // FIXME #7809: This shouldn't be pub, and it should be reexported under 'unstable'
207 // but name resolution doesn't work without it being pub.
208 pub mod rt;
209
210 // A curious inner-module that's not exported that contains the binding
211 // 'std' so that macro-expanded references to std::error and such
212 // can be resolved within libstd.
213 #[doc(hidden)]
214 mod std {
215     pub use clone;
216     pub use cmp;
217     pub use condition;
218     pub use fmt;
219     pub use kinds;
220     pub use local_data;
221     pub use logging;
222     pub use logging;
223     pub use option;
224     pub use os;
225     pub use rt;
226     pub use str;
227     pub use to_bytes;
228     pub use to_str;
229     pub use unstable;
230 }