Skip to content

Commit 9b3d315

Browse files
committed
std: Update crate docs
Attempted to organize them in a way more relevant to what newbies would be interested in hearing.
1 parent 5a83fa2 commit 9b3d315

File tree

3 files changed

+49
-53
lines changed

3 files changed

+49
-53
lines changed

src/libstd/lib.rs

Lines changed: 47 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,35 @@
1212
//!
1313
//! The Rust Standard Library provides the essential runtime
1414
//! functionality for building portable Rust software.
15-
//! It is linked to all Rust crates by default.
1615
//!
17-
//! ## Intrinsic types and operations
16+
//! It is linked to all Rust crates by default as though they
17+
//! contained a crate-level `extern crate std` crate import. Therefore
18+
//! the standard library can be accessed in `use` statements through
19+
//! the path `std`, as in `use std::thread`, or in expressions through
20+
//! the absolute path `::std`, as in `::std::thread::sleep_ms(100)`.
1821
//!
19-
//! The [`ptr`](ptr/index.html) and [`mem`](mem/index.html)
20-
//! modules deal with unsafe pointers and memory manipulation.
21-
//! [`marker`](marker/index.html) defines the special built-in traits,
22-
//! and [`raw`](raw/index.html) the runtime representation of Rust types.
23-
//! These are some of the lowest-level building blocks in Rust.
22+
//! Furthermore, the standard library defines [The Rust
23+
//! Prelude](prelude/index.html), a small collection of items, mostly
24+
//! traits, that are imported into and available in every module.
2425
//!
25-
//! ## Math on primitive types and math traits
26+
//! ## What is in the standard library
2627
//!
27-
//! Although basic operations on primitive types are implemented
28-
//! directly by the compiler, the standard library additionally
29-
//! defines many common operations through traits defined in
30-
//! mod [`num`](num/index.html).
28+
//! The standard library is minimal, a set of battle-tested
29+
//! core types and shared abstractions for the [broader Rust
30+
//! ecosystem][https://crates.io] to build on.
3131
//!
32-
//! ## Pervasive types
32+
//! The [primitive types](#primitives), though not defined in the
33+
//! standard library, are documented here, as are the predefined
34+
//! [macros](#macros).
3335
//!
34-
//! The [`option`](option/index.html) and [`result`](result/index.html)
35-
//! modules define optional and error-handling types, `Option` and `Result`.
36-
//! [`iter`](iter/index.html) defines Rust's iterator protocol
37-
//! along with a wide variety of iterators.
38-
//! [`Cell` and `RefCell`](cell/index.html) are for creating types that
39-
//! manage their own mutability.
36+
//! ## Containers and collections
4037
//!
41-
//! ## Vectors, slices and strings
38+
//! The [`option`](option/index.html) and
39+
//! [`result`](result/index.html) modules define optional and
40+
//! error-handling types, `Option` and `Result`. The
41+
//! [`iter`](iter/index.html) module defines Rust's iterator trait,
42+
//! [`Iterater`](iter/trait.Iterator.html), which works with the `for`
43+
//! loop to access collections.
4244
//!
4345
//! The common container type, `Vec`, a growable vector backed by an array,
4446
//! lives in the [`vec`](vec/index.html) module. Contiguous, unsized regions
@@ -56,42 +58,36 @@
5658
//! macro, and for converting from strings use the
5759
//! [`FromStr`](str/trait.FromStr.html) trait.
5860
//!
59-
//! ## Platform abstractions
61+
//! Data may be shared by placing it a reference-counted box, the
62+
//! [`Rc`][rc/index.html] type, and if further contained in a [`Cell`
63+
//! or `RefCell`](cell/index.html), may be mutated as well as shared.
64+
//! Likewise, in a concurrent setting it is common to pair an
65+
//! atomically-reference-counted box, [`Arc`](sync/struct.Arc.html),
66+
//! with a [`Mutex`](sync/struct.Mutex.html) to get the same effect.
6067
//!
61-
//! Besides basic data types, the standard library is largely concerned
62-
//! with abstracting over differences in common platforms, most notably
63-
//! Windows and Unix derivatives. The [`os`](os/index.html) module
64-
//! provides a number of basic functions for interacting with the
65-
//! operating environment, including program arguments, environment
66-
//! variables, and directory navigation. The [`path`](path/index.html)
67-
//! module encapsulates the platform-specific rules for dealing
68-
//! with file paths.
69-
//!
70-
//! `std` also includes the [`ffi`](ffi/index.html) module for interoperating
71-
//! with the C language.
72-
//!
73-
//! ## Concurrency, I/O, and the runtime
68+
//! The [`collections`](collections/index.html) module defines maps,
69+
//! sets, linked lists and other typical collection types, including
70+
//! the common [`HashMap`](collections/struct.HashMap.html).
7471
//!
75-
//! The [`thread`](thread/index.html) module contains Rust's threading abstractions.
76-
//! [`sync`](sync/index.html) contains further, primitive, shared memory types,
77-
//! including [`atomic`](sync/atomic/index.html), and [`mpsc`](sync/mpsc/index.html),
78-
//! which contains the channel types for message passing.
72+
//! ## Platform abstractions and I/O
7973
//!
80-
//! Common types of I/O, including files, TCP, UDP, pipes, Unix domain sockets, and
81-
//! process spawning, are defined in the [`io`](io/index.html) module.
82-
//!
83-
//! Rust's I/O and concurrency depends on a small runtime interface
84-
//! that lives, along with its support code, in mod [`rt`](rt/index.html).
85-
//! While a notable part of the standard library's architecture, this
86-
//! module is not intended for public use.
74+
//! Besides basic data types, the standard library is largely concerned
75+
//! with abstracting over differences in common platforms, most notably
76+
//! Windows and Unix derivatives.
8777
//!
88-
//! ## The Rust prelude and macros
78+
//! Common types of I/O, including [files](fs/struct.File.html),
79+
//! [TCP](net/struct.TcpStream.html),
80+
//! [UDP](net/struct.UdpSocket.html), are defined in the
81+
//! [`io`](io/index.html), [`fs`](fs/index.html), and
82+
//! [`net`](net/index.html) modulesu.
8983
//!
90-
//! Finally, the [`prelude`](prelude/index.html) defines a
91-
//! common set of traits, types, and functions that are made available
92-
//! to all code by default. [`macros`](macros/index.html) contains
93-
//! all the standard macros, such as `assert!`, `panic!`, `println!`,
94-
//! and `format!`, also available to all Rust code.
84+
//! The [`thread`](thread/index.html) module contains Rust's threading
85+
//! abstractions. [`sync`](sync/index.html) contains further,
86+
//! primitive, shared memory types, including
87+
//! [`atomic`](sync/atomic/index.html), and
88+
//! [`mpsc`](sync/mpsc/index.html), which contains the channel types
89+
//! for message passing.
90+
9591
// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364)
9692
#![cfg_attr(stage0, feature(custom_attribute))]
9793
#![crate_name = "std"]

src/libstd/prelude/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! The Rust prelude
11+
//! The Rust Prelude
1212
//!
1313
//! Because `std` is required by most serious Rust software, it is
1414
//! imported at the topmost level of every crate by default, as if the

src/libstd/prelude/v1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! The first version of the prelude of the standard library.
11+
//! The first version of the prelude of The Rust Standard Library.
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414

0 commit comments

Comments
 (0)