|
14 | 14 | //! software, a set of minimal and battle-tested shared abstractions
|
15 | 15 | //! for the [broader Rust ecosystem](https://crates.io). It offers
|
16 | 16 | //! core types (e.g. [`Vec`](vec/index.html)
|
17 |
| -//! and[`Option`](option/index.html)), library-defined [operations on |
| 17 | +//! and [`Option`](option/index.html)), library-defined [operations on |
18 | 18 | //! language primitives](#primitive) (e.g. [`u32`](u32/index.html) and
|
19 | 19 | //! [`str`](str/index.html)), [standard macros](#macros),
|
20 | 20 | //! [I/O](io/index.html) and [multithreading](thread/index.html), among
|
|
32 | 32 | //! [book-crate-root]: ../book/crates-and-modules.html#basic-terminology:-crates-and-modules
|
33 | 33 | //! [book-use]: ../book/crates-and-modules.html#importing-modules-with-use
|
34 | 34 | //!
|
35 |
| -//! Furthermore, the standard library defines [The Rust |
36 |
| -//! Prelude](prelude/index.html), a small collection of items, mostly |
37 |
| -//! traits, that are imported into every module and through trait |
38 |
| -//! resolution provide Rust with much of its *standard flavor*. |
39 |
| -//! |
40 | 35 | //! # How to read this documentation
|
41 | 36 | //!
|
42 | 37 | //! If you already know the name of what you are looking for the
|
43 | 38 | //! fastest way to find it is to use the <a href="#"
|
44 |
| -//! onclick="document.getElementsByName('search')[0].focus();">search |
45 |
| -//! bar</a> at the top of the page. |
| 39 | +//! onclick="focusSearchBar();">search bar</a> at the top of the page. |
46 | 40 | //!
|
47 | 41 | //! Otherwise, you may want to jump to one of these useful sections:
|
48 | 42 | //!
|
|
52 | 46 | //! * [The Rust Prelude](prelude/index.html)
|
53 | 47 | //!
|
54 | 48 | //! If this is your first time, the documentation for the standard
|
55 |
| -//! library is written to be casually perused and clicking on |
56 |
| -//! interesting things should generally lead you to interesting |
57 |
| -//! places. Still, there are important bits you don't want to miss, so |
58 |
| -//! read on for a tour of the standard library and its documentation. |
| 49 | +//! library is written to be casually perused. Clicking on interesting |
| 50 | +//! things should generally lead you to interesting places. Still, |
| 51 | +//! there are important bits you don't want to miss, so read on for a |
| 52 | +//! tour of the standard library and its documentation! |
59 | 53 | //!
|
60 | 54 | //! Once you are familiar with the contents of the standard library
|
61 | 55 | //! you may begin to find the verbosity of the prose distracting. At
|
|
81 | 75 | //! includes an overview of the module along with examples, and are
|
82 | 76 | //! a smart place to start familiarizing yourself with the library.
|
83 | 77 | //!
|
84 |
| -//! Secondly, implicit methods on [primitive |
| 78 | +//! Second, implicit methods on [primitive |
85 | 79 | //! types](../book/primitive-types.html) are documented here. This can
|
86 | 80 | //! be a source of confusion for two reasons:
|
87 | 81 | //!
|
|
109 | 103 | //! primitive types are documented on their own pages will bring you a
|
110 | 104 | //! deep inner wisdom. Embrace it now before proceeding.*
|
111 | 105 | //!
|
112 |
| -//! Thirdly, the standard library defines [The Rust |
| 106 | +//! Third, the standard library defines [The Rust |
113 | 107 | //! Prelude](prelude/index.html), a small collection of items - mostly
|
114 |
| -//! traits - that are imported into every module. The traits in the |
115 |
| -//! prelude are pervasive, making the prelude documentation a good |
116 |
| -//! entry point to learning about the library. |
| 108 | +//! traits - that are imported into every module of every crate. The |
| 109 | +//! traits in the prelude are pervasive, making the prelude |
| 110 | +//! documentation a good entry point to learning about the library. |
117 | 111 | //!
|
118 |
| -//! And lastly, the standard library exports a number of standard |
| 112 | +//! And finally, the standard library exports a number of standard |
119 | 113 | //! macros, and [lists them on this page](#macros) (technically, not
|
120 | 114 | //! all of the standard macros are defined by the standard library -
|
121 | 115 | //! some are defined by the compiler - but they are documented here
|
122 |
| -//! the same). Like the prelude, the standard macros are imported by |
| 116 | +//! the same). Like the prelude, the standard macros are imported by |
123 | 117 | //! default into all crates.
|
124 | 118 | //!
|
125 | 119 | //! # A Tour of The Rust Standard Library
|
|
136 | 130 | //! [`Iterator`](iter/trait.Iterator.html), which works with the `for`
|
137 | 131 | //! loop to access collections.
|
138 | 132 | //!
|
139 |
| -//! The common container type, `Vec`, a growable vector backed by an |
140 |
| -//! array, lives in the [`vec`](vec/index.html) module. Contiguous, |
141 |
| -//! unsized regions of memory, `[T]`, commonly called "slices", and |
142 |
| -//! their borrowed versions, `&[T]`, commonly called "borrowed |
143 |
| -//! slices", are primitive types [with many implicit |
144 |
| -//! methods](primitive.slice.html) defined by the standard library. |
145 |
| -//! |
146 |
| -//! `str`, a UTF-8 string, is a primitive type, and the standard |
147 |
| -//! library defines [many methods for it](primitive.str.html). |
148 |
| -//! Rust `str`s are immutable; use the owned `String` type |
149 |
| -//! defined in [`string`](string/index.html) for building and mutating |
150 |
| -//! strings. |
| 133 | +//! The standard library exposes 3 common ways to deal with contiguous |
| 134 | +//! regions of memory: |
| 135 | +//! |
| 136 | +//! * [`Vec<T>`](vec/index.html) - A heap-allocated *vector* that is |
| 137 | +//! resizable at runtime. |
| 138 | +//! * [`[T; n]`](primitive.array.html) - An inline *array* with a |
| 139 | +//! fixed size at compile time. |
| 140 | +//! * [`[T]`](primitive.slice.html) - A dynamically sized *slice* into |
| 141 | +//! any other kind of contiguous storage, whether heap-allocated or |
| 142 | +//! not. |
| 143 | +//! |
| 144 | +//! Slices can only be handled through some kind of *pointer*, and as |
| 145 | +//! such come in many flavours such as: |
| 146 | +//! |
| 147 | +//! * `&[T]` - *shared slice* |
| 148 | +//! * `&mut [T]` - *mutable slice* |
| 149 | +//! * [`Box<[T]>`](boxed/index.html) - *owned slice* |
| 150 | +//! |
| 151 | +//! `str`, a UTF-8 string slice, is a primitive type, and the standard |
| 152 | +//! library defines [many methods for it](primitive.str.html). Rust |
| 153 | +//! `str`s are immutable; use the owned `String` type defined in |
| 154 | +//! [`string`](string/index.html) for building and mutating strings. |
151 | 155 | //!
|
152 | 156 | //! For converting to strings use the [`format!`](fmt/index.html)
|
153 | 157 | //! macro, and for converting from strings use the
|
|
0 commit comments