|
10 | 10 |
|
11 | 11 | /*! |
12 | 12 |
|
13 | | -The Rust core library |
| 13 | +# The Rust core library |
14 | 14 |
|
15 | 15 | The Rust core library provides runtime features required by the language, |
16 | 16 | including the task scheduler and memory allocators, as well as library |
17 | 17 | support for Rust built-in types, platform abstractions, and other commonly |
18 | 18 | used features. |
19 | 19 |
|
20 | 20 | `core` includes modules corresponding to each of the integer types, each of |
21 | | -the floating point types, the `bool` type, tuples, characters, strings, |
22 | | -vectors (`vec`), managed boxes (`managed`), owned boxes (`owned`), and unsafe |
23 | | -and borrowed pointers (`ptr`). Additionally, `core` provides task management |
24 | | -and creation (`task`), communication primitives (`comm` and `pipes`), platform |
25 | | -abstractions (`os` and `path`), basic I/O abstractions (`io`), common traits |
26 | | -(`cmp`, `num`, `to_str`), and complete bindings to the C standard library |
27 | | -(`libc`). |
| 21 | +the floating point types, the `bool` type, tuples, characters, strings |
| 22 | +(`str`), vectors (`vec`), managed boxes (`managed`), owned boxes (`owned`), |
| 23 | +and unsafe and borrowed pointers (`ptr`). Additionally, `core` provides |
| 24 | +pervasive types (`option` and `result`), task creation and communication |
| 25 | +primitives (`task`, `comm`), platform abstractions (`os` and `path`), basic |
| 26 | +I/O abstractions (`io`), common traits (`kinds`, `ops`, `cmp`, `num`, |
| 27 | +`to_str`), and complete bindings to the C standard library (`libc`). |
28 | 28 |
|
29 | | -`core` is linked to all crates by default and its contents imported. |
30 | | -Implicitly, all crates behave as if they included the following prologue: |
| 29 | +# Core injection and the Rust prelude |
| 30 | + |
| 31 | +`core` is imported at the topmost level of every crate by default, as |
| 32 | +if the first line of each crate was |
31 | 33 |
|
32 | 34 | extern mod core; |
33 | | - use core::*; |
| 35 | + |
| 36 | +This means that the contents of core can be accessed from from any context |
| 37 | +with the `core::` path prefix, as in `use core::vec`, `use core::task::spawn`, |
| 38 | +etc. |
| 39 | + |
| 40 | +Additionally, `core` contains a `prelude` module that reexports many of the |
| 41 | +most common core modules, types and traits. The contents of the prelude are |
| 42 | +imported inte every *module* by default. Implicitly, all modules behave as if |
| 43 | +they contained the following prologue: |
| 44 | + |
| 45 | + use core::prelude::*; |
34 | 46 |
|
35 | 47 | */ |
36 | 48 |
|
|
0 commit comments