rust/src/libstd/lib.rs

231 lines
5.8 KiB
Rust
Raw Normal View History

2013-02-28 07:15:32 -06:00
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! # The Rust standard library
//!
//! The Rust standard library is a group of interrelated modules defining
//! the core language traits, operations on built-in data types, collections,
//! platform abstractions, the task scheduler, runtime support for language
//! features and other common functionality.
//!
//! `std` includes modules corresponding to each of the integer types,
//! each of the floating point types, the `bool` type, tuples, characters,
//! strings (`str`), vectors (`vec`), managed boxes (`managed`), owned
//! boxes (`owned`), and unsafe and borrowed pointers (`ptr`, `borrowed`).
//! Additionally, `std` provides pervasive types (`option` and `result`),
//! task creation and communication primitives (`task`, `comm`), platform
//! abstractions (`os` and `path`), basic I/O abstractions (`rt::io`), common
//! traits (`kinds`, `ops`, `cmp`, `num`, `to_str`), and complete bindings
//! to the C standard library (`libc`).
//!
//! # Standard library injection and the Rust prelude
//!
//! `std` is imported at the topmost level of every crate by default, as
//! if the first line of each crate was
//!
//! extern mod std;
//!
//! This means that the contents of std can be accessed from any context
//! with the `std::` path prefix, as in `use std::vec`, `use std::task::spawn`,
//! etc.
//!
//! Additionally, `std` contains a `prelude` module that reexports many of the
//! most common types, traits and functions. The contents of the prelude are
//! imported into every *module* by default. Implicitly, all modules behave as if
//! they contained the following prologue:
//!
//! use std::prelude::*;
#[link(name = "std",
2013-09-26 20:18:42 -05:00
vers = "0.9-pre",
uuid = "c70c24a7-5551-4f73-8e37-380b11d80be8",
url = "https://github.com/mozilla/rust/tree/master/src/libstd")];
#[comment = "The Rust standard library"];
#[license = "MIT/ASL2"];
#[crate_type = "lib"];
#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
rustdoc: Generate hyperlinks between crates The general idea of hyperlinking between crates is that it should require as little configuration as possible, if any at all. In this vein, there are two separate ways to generate hyperlinks between crates: 1. When you're generating documentation for a crate 'foo' into folder 'doc', then if foo's external crate dependencies already have documented in the folder 'doc', then hyperlinks will be generated. This will work because all documentation is in the same folder, allowing links to work seamlessly both on the web and on the local filesystem browser. The rationale for this use case is a package with multiple libraries/crates that all want to link to one another, and you don't want to have to deal with going to the web. In theory this could be extended to have a RUST_PATH-style searching situtation, but I'm not sure that it would work seamlessly on the web as it does on the local filesystem, so I'm not attempting to explore this case in this pull request. I believe to fully realize this potential rustdoc would have to be acting as a server instead of a static site generator. 2. One of foo's external dependencies has a #[doc(html_root_url = "...")] attribute. This means that all hyperlinks to the dependency will be rooted at this url. This use case encompasses all packages using libstd/libextra. These two crates now have this attribute encoded (currently at the /doc/master url) and will be read by anything which has a dependency on libstd/libextra. This should also work for arbitrary crates in the wild that have online documentation. I don't like how the version is hard-wired into the url, but I think that this may be a case-by-case thing which doesn't end up being too bad in the long run. Closes #9539
2013-10-02 17:39:32 -05:00
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://static.rust-lang.org/doc/master")];
2013-10-23 03:49:18 -05:00
#[feature(macro_rules, globs, asm, managed_boxes)];
// Don't link to std. We are std.
#[no_std];
2012-04-19 03:00:52 -05:00
#[deny(non_camel_case_types)];
#[deny(missing_doc)];
// When testing libstd, bring in libuv as the I/O backend so tests can print
// things and all of the std::rt::io tests have an I/O interface to run on top
// of
#[cfg(test)] extern mod rustuv(vers = "0.9-pre");
// Make extra accessible for benchmarking
#[cfg(test)] extern mod extra(vers = "0.9-pre");
// Make std testable by not duplicating lang items. See #2912
#[cfg(test)] extern mod realstd(name = "std");
#[cfg(test)] pub use kinds = realstd::kinds;
#[cfg(test)] pub use ops = realstd::ops;
#[cfg(test)] pub use cmp = realstd::cmp;
2013-03-06 21:09:17 -06:00
// On Linux, link to the runtime with -lrt.
#[cfg(target_os = "linux")]
2013-03-13 21:12:43 -05:00
#[doc(hidden)]
2013-03-06 21:09:17 -06:00
pub mod linkhack {
#[link_args="-lrustrt -lrt"]
#[link_args = "-lpthread"]
2013-03-06 21:09:17 -06:00
extern {
}
}
/* The Prelude. */
pub mod prelude;
/* Primitive types */
#[path = "num/int_macros.rs"] mod int_macros;
#[path = "num/uint_macros.rs"] mod uint_macros;
#[path = "num/int.rs"] pub mod int;
#[path = "num/i8.rs"] pub mod i8;
#[path = "num/i16.rs"] pub mod i16;
#[path = "num/i32.rs"] pub mod i32;
#[path = "num/i64.rs"] pub mod i64;
#[path = "num/uint.rs"] pub mod uint;
#[path = "num/u8.rs"] pub mod u8;
#[path = "num/u16.rs"] pub mod u16;
#[path = "num/u32.rs"] pub mod u32;
#[path = "num/u64.rs"] pub mod u64;
#[path = "num/f32.rs"] pub mod f32;
#[path = "num/f64.rs"] pub mod f64;
pub mod unit;
2012-10-03 21:24:06 -05:00
pub mod bool;
pub mod char;
2012-10-03 21:24:06 -05:00
pub mod tuple;
pub mod vec;
pub mod at_vec;
pub mod str;
pub mod ascii;
pub mod send_str;
pub mod ptr;
pub mod owned;
pub mod managed;
pub mod borrow;
pub mod rc;
/* Core language traits */
#[cfg(not(test))] pub mod kinds;
#[cfg(not(test))] pub mod ops;
#[cfg(not(test))] pub mod cmp;
/* Common traits */
pub mod from_str;
2012-10-03 21:24:06 -05:00
pub mod num;
pub mod iter;
2012-10-03 21:24:06 -05:00
pub mod to_str;
pub mod to_bytes;
2012-11-26 18:12:47 -06:00
pub mod clone;
pub mod hash;
pub mod container;
2013-08-10 08:38:00 -05:00
pub mod default;
pub mod any;
/* Common data structures */
pub mod option;
pub mod result;
pub mod either;
pub mod hashmap;
pub mod cell;
pub mod trie;
/* Tasks and communication */
2012-11-28 14:33:00 -06:00
pub mod task;
2013-02-02 05:10:12 -06:00
pub mod comm;
pub mod select;
pub mod local_data;
/* Runtime and platform support */
2012-10-03 21:24:06 -05:00
pub mod libc;
pub mod c_str;
2012-10-03 21:24:06 -05:00
pub mod os;
pub mod path;
pub mod rand;
pub mod run;
pub mod cast;
pub mod fmt;
2012-10-03 21:24:06 -05:00
pub mod repr;
pub mod cleanup;
pub mod reflect;
pub mod condition;
pub mod logging;
pub mod util;
pub mod routine;
pub mod mem;
/* Unsupported interfaces */
// Private APIs
pub mod unstable;
/* For internal use, not exported */
mod unicode;
#[path = "num/cmath.rs"]
mod cmath;
// FIXME #7809: This shouldn't be pub, and it should be reexported under 'unstable'
// but name resolution doesn't work without it being pub.
pub mod rt;
2012-11-28 14:33:00 -06:00
// A curious inner-module that's not exported that contains the binding
// 'std' so that macro-expanded references to std::error and such
// can be resolved within libstd.
#[doc(hidden)]
mod std {
pub use clone;
pub use cmp;
pub use condition;
pub use fmt;
pub use kinds;
pub use local_data;
pub use logging;
pub use logging;
pub use option;
pub use os;
pub use rt;
pub use str;
pub use to_bytes;
pub use to_str;
pub use unstable;
}