2017-07-15 16:26:00 +00:00
|
|
|
# The Rust Language Reference
|
|
|
|
|
2024-02-19 05:56:24 +00:00
|
|
|
This document is the primary reference for the Rust programming
|
|
|
|
language.
|
2017-07-15 16:26:00 +00:00
|
|
|
|
|
|
|
This document is not normative. It may include details that are specific
|
|
|
|
to `rustc` itself, and should not be taken as a specification for the
|
|
|
|
Rust language. We intend to produce such a document someday, but this is
|
|
|
|
what we have for now.
|
|
|
|
|
|
|
|
## Dependencies
|
|
|
|
|
2024-02-19 06:25:59 +00:00
|
|
|
- Nightly Rust
|
|
|
|
- [mdbook](https://rust-lang.github.io/mdBook/)
|
2017-07-15 16:26:00 +00:00
|
|
|
|
2024-02-19 06:25:59 +00:00
|
|
|
## Installing dependencies
|
2017-07-15 16:26:00 +00:00
|
|
|
|
2024-02-19 06:25:59 +00:00
|
|
|
First, ensure that you have a recent copy of the nightly Rust compiler
|
|
|
|
installed, as this is needed in order to run the tests:
|
2021-01-17 16:00:02 +00:00
|
|
|
|
2024-02-19 06:25:59 +00:00
|
|
|
```sh
|
|
|
|
rustup toolchain install nightly
|
2021-01-17 16:00:02 +00:00
|
|
|
```
|
|
|
|
|
2024-02-19 06:25:59 +00:00
|
|
|
Now, ensure you have `mdbook` installed, as this is needed in order to
|
|
|
|
build the Reference:
|
2017-07-15 16:26:00 +00:00
|
|
|
|
2020-06-02 15:43:00 +00:00
|
|
|
```sh
|
2024-02-19 06:25:59 +00:00
|
|
|
cargo install --locked mdbook
|
2021-01-17 16:00:02 +00:00
|
|
|
```
|
2021-01-27 17:19:34 +00:00
|
|
|
|
2024-02-19 06:25:59 +00:00
|
|
|
## Building
|
|
|
|
|
|
|
|
To build the Reference, first clone the project:
|
2021-01-27 17:19:34 +00:00
|
|
|
|
2024-02-19 06:25:59 +00:00
|
|
|
```sh
|
|
|
|
git clone https://github.com/rust-lang/reference.git
|
2021-01-27 17:19:34 +00:00
|
|
|
```
|
|
|
|
|
2024-02-19 06:25:59 +00:00
|
|
|
(Alternatively, if you don't want to use `git`, [download][] a ZIP file
|
|
|
|
of the project, extract it using your preferred tool, and rename the
|
|
|
|
top-level directory to `reference`.)
|
2021-01-27 17:19:34 +00:00
|
|
|
|
2024-02-19 06:25:59 +00:00
|
|
|
[download]: https://github.com/rust-lang/reference/archive/refs/heads/master.zip
|
2021-01-27 17:19:34 +00:00
|
|
|
|
2024-02-19 06:25:59 +00:00
|
|
|
Now change your current directory to the working directory:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
cd reference
|
2021-01-27 17:19:34 +00:00
|
|
|
```
|
|
|
|
|
2024-02-19 06:25:59 +00:00
|
|
|
To test all of the code examples in the Reference, run:
|
2021-01-17 16:00:02 +00:00
|
|
|
|
2024-02-19 06:25:59 +00:00
|
|
|
```sh
|
2017-07-15 16:26:00 +00:00
|
|
|
mdbook test
|
|
|
|
```
|
|
|
|
|
2024-02-19 06:25:59 +00:00
|
|
|
To build the Reference locally (in `build/`) and open it in a web
|
|
|
|
browser, run:
|
2017-07-15 16:26:00 +00:00
|
|
|
|
2020-06-02 15:43:00 +00:00
|
|
|
```sh
|
2024-02-19 06:25:59 +00:00
|
|
|
mdbook build --open
|
2017-07-15 16:26:00 +00:00
|
|
|
```
|