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.
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.
11 //! # The Rust Standard Library
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.
17 //! ## Intrinsic types and operations
19 //! The [`ptr`](../core/ptr/index.html), [`mem`](../core/mem/index.html),
20 //! and [`cast`](../core/cast/index.html) modules deal with unsafe pointers,
21 //! memory manipulation, and coercion.
22 //! [`kinds`](../core/kinds/index.html) defines the special built-in traits,
23 //! and [`raw`](../core/raw/index.html) the runtime representation of Rust types.
24 //! These are some of the lowest-level building blocks of Rust
27 //! ## Math on primitive types and math traits
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).
34 //! ## Pervasive types
36 //! The [`option`](option/index.html) and [`result`](result/index.html)
37 //! modules define optional and error-handling types, `Option` and `Result`.
38 //! [`iter`](../core/iter/index.html) defines Rust's iterator protocol
39 //! along with a wide variety of iterators.
40 //! [`Cell` and `RefCell`](../core/cell/index.html) are for creating types that
41 //! manage their own mutability.
43 //! ## Vectors, slices and strings
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
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.
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.
61 //! ## Platform abstractions
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
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).
76 //! ## Concurrency, I/O, and the runtime
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).
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.
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.
91 //! ## The Rust prelude and macros
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.
99 #![crate_id = "std#0.11.0-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)]
110 // Don't link to std. We are std.
113 #![allow(deprecated)]
114 #![deny(missing_doc)]
116 // When testing libstd, bring in libuv as the I/O backend so tests can print
117 // things and all of the std::io tests have an I/O interface to run on top
119 #[cfg(test)] extern crate rustuv;
120 #[cfg(test)] extern crate native;
121 #[cfg(test)] extern crate green;
122 #[cfg(test)] #[phase(syntax, link)] extern crate log;
124 // Make and rand accessible for benchmarking/testcases
125 #[cfg(test)] extern crate rand;
130 // Make std testable by not duplicating lang items. See #2912
131 #[cfg(test)] extern crate realstd = "std";
132 #[cfg(test)] pub use kinds = realstd::kinds;
133 #[cfg(test)] pub use ops = realstd::ops;
134 #[cfg(test)] pub use cmp = realstd::cmp;
135 #[cfg(test)] pub use ty = realstd::ty;
136 #[cfg(test)] pub use owned = realstd::owned;
138 #[cfg(not(test))] pub use cmp = core::cmp;
139 #[cfg(not(test))] pub use kinds = core::kinds;
140 #[cfg(not(test))] pub use ops = core::ops;
141 #[cfg(not(test))] pub use ty = core::ty;
148 pub use core::container;
149 pub use core::default;
150 pub use core::intrinsics;
157 // Run tests with libgreen instead of libnative.
159 // FIXME: This egregiously hacks around starting the test runner in a different
160 // threading mode than the default by reaching into the auto-generated
162 #[cfg(test)] #[start]
163 fn start(argc: int, argv: **u8) -> int {
164 green::start(argc, argv, rustuv::event_loop, __test::main)
167 /* Exported macros */
179 /* Primitive types */
181 #[path = "num/float_macros.rs"] mod float_macros;
182 #[path = "num/int_macros.rs"] mod int_macros;
183 #[path = "num/uint_macros.rs"] mod uint_macros;
185 #[path = "num/int.rs"] pub mod int;
186 #[path = "num/i8.rs"] pub mod i8;
187 #[path = "num/i16.rs"] pub mod i16;
188 #[path = "num/i32.rs"] pub mod i32;
189 #[path = "num/i64.rs"] pub mod i64;
191 #[path = "num/uint.rs"] pub mod uint;
192 #[path = "num/u8.rs"] pub mod u8;
193 #[path = "num/u16.rs"] pub mod u16;
194 #[path = "num/u32.rs"] pub mod u32;
195 #[path = "num/u64.rs"] pub mod u64;
197 #[path = "num/f32.rs"] pub mod f32;
198 #[path = "num/f64.rs"] pub mod f64;
219 /* Common data structures */
224 /* Tasks and communication */
232 /* Runtime and platform support */
242 /* Unsupported interfaces */
253 /* For internal use, not exported */
257 // FIXME #7809: This shouldn't be pub, and it should be reexported under 'unstable'
258 // but name resolution doesn't work without it being pub.
262 // A curious inner-module that's not exported that contains the binding
263 // 'std' so that macro-expanded references to std::error and such
264 // can be resolved within libstd.
284 // The test runner requires std::slice::Vector, so re-export std::slice just for it.
285 #[cfg(test)] pub use slice;