2015-12-11 22:50:02 +00:00
|
|
|
# The Rust Programming Language
|
|
|
|
|
2020-05-23 04:39:45 +00:00
|
|
|
![Build Status](https://github.com/rust-lang/book/workflows/CI/badge.svg)
|
2016-08-10 23:30:49 +00:00
|
|
|
|
2019-01-06 01:11:01 +00:00
|
|
|
This repository contains the source of "The Rust Programming Language" book.
|
2017-03-26 15:15:19 +00:00
|
|
|
|
2019-09-29 01:43:25 +00:00
|
|
|
[The book is available in dead-tree form from No Starch Press][nostarch].
|
2017-03-26 15:15:19 +00:00
|
|
|
|
2023-01-21 10:18:33 +00:00
|
|
|
[nostarch]: https://nostarch.com/rust-programming-language-2nd-edition
|
2015-12-11 22:50:02 +00:00
|
|
|
|
2019-01-06 01:11:01 +00:00
|
|
|
You can also read the book for free online. Please see the book as shipped with
|
2018-12-12 14:59:58 +00:00
|
|
|
the latest [stable], [beta], or [nightly] Rust releases. Be aware that issues
|
|
|
|
in those versions may have been fixed in this repository already, as those
|
|
|
|
releases are updated less frequently.
|
2015-12-14 20:00:58 +00:00
|
|
|
|
2018-04-05 16:43:05 +00:00
|
|
|
[stable]: https://doc.rust-lang.org/stable/book/
|
|
|
|
[beta]: https://doc.rust-lang.org/beta/book/
|
|
|
|
[nightly]: https://doc.rust-lang.org/nightly/book/
|
2017-11-27 20:48:13 +00:00
|
|
|
|
2019-09-29 01:43:25 +00:00
|
|
|
See the [releases] to download just the code of all the code listings that appear in the book.
|
|
|
|
|
|
|
|
[releases]: https://github.com/rust-lang/book/releases
|
|
|
|
|
2015-12-11 22:50:02 +00:00
|
|
|
## Requirements
|
|
|
|
|
2020-07-27 19:29:25 +00:00
|
|
|
Building the book requires [mdBook], ideally the same version that
|
2019-03-23 19:45:46 +00:00
|
|
|
rust-lang/rust uses in [this file][rust-mdbook]. To get it:
|
2015-12-11 22:50:02 +00:00
|
|
|
|
2023-11-05 21:25:22 +00:00
|
|
|
[mdBook]: https://github.com/rust-lang/mdBook
|
2017-10-26 16:32:51 +00:00
|
|
|
[rust-mdbook]: https://github.com/rust-lang/rust/blob/master/src/tools/rustbook/Cargo.toml
|
2015-12-11 22:50:02 +00:00
|
|
|
|
2017-03-13 19:03:58 +00:00
|
|
|
```bash
|
2024-01-29 18:36:04 +00:00
|
|
|
$ cargo install mdbook --locked --version <version_num>
|
2015-12-11 22:50:02 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Building
|
|
|
|
|
2018-12-12 14:59:58 +00:00
|
|
|
To build the book, type:
|
2015-12-11 22:50:02 +00:00
|
|
|
|
2017-03-13 19:03:58 +00:00
|
|
|
```bash
|
2016-01-21 00:31:27 +00:00
|
|
|
$ mdbook build
|
2015-12-11 22:50:02 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
The output will be in the `book` subdirectory. To check it out, open it in
|
2016-08-24 04:59:18 +00:00
|
|
|
your web browser.
|
2015-12-11 22:50:02 +00:00
|
|
|
|
2016-08-24 04:59:18 +00:00
|
|
|
_Firefox:_
|
2017-03-13 19:03:58 +00:00
|
|
|
```bash
|
2017-03-11 19:42:01 +00:00
|
|
|
$ firefox book/index.html # Linux
|
|
|
|
$ open -a "Firefox" book/index.html # OS X
|
|
|
|
$ Start-Process "firefox.exe" .\book\index.html # Windows (PowerShell)
|
|
|
|
$ start firefox.exe .\book\index.html # Windows (Cmd)
|
2015-12-11 22:50:02 +00:00
|
|
|
```
|
|
|
|
|
2016-08-24 04:59:18 +00:00
|
|
|
_Chrome:_
|
2017-03-13 19:03:58 +00:00
|
|
|
```bash
|
2017-03-11 19:42:01 +00:00
|
|
|
$ google-chrome book/index.html # Linux
|
|
|
|
$ open -a "Google Chrome" book/index.html # OS X
|
|
|
|
$ Start-Process "chrome.exe" .\book\index.html # Windows (PowerShell)
|
|
|
|
$ start chrome.exe .\book\index.html # Windows (Cmd)
|
2016-08-24 04:57:53 +00:00
|
|
|
```
|
|
|
|
|
2015-12-14 17:11:06 +00:00
|
|
|
To run the tests:
|
|
|
|
|
2017-03-13 19:03:58 +00:00
|
|
|
```bash
|
2016-01-21 00:31:27 +00:00
|
|
|
$ mdbook test
|
2015-12-14 17:11:06 +00:00
|
|
|
```
|
|
|
|
|
2015-12-11 22:50:02 +00:00
|
|
|
## Contributing
|
|
|
|
|
2017-03-26 15:15:19 +00:00
|
|
|
We'd love your help! Please see [CONTRIBUTING.md][contrib] to learn about the
|
|
|
|
kinds of contributions we're looking for.
|
2015-12-11 22:50:02 +00:00
|
|
|
|
2021-11-16 21:54:27 +00:00
|
|
|
[contrib]: https://github.com/rust-lang/book/blob/main/CONTRIBUTING.md
|
2015-12-18 19:48:16 +00:00
|
|
|
|
2023-01-21 10:18:33 +00:00
|
|
|
Because the book is [printed][nostarch], and because we want
|
2021-07-27 00:19:46 +00:00
|
|
|
to keep the online version of the book close to the print version when
|
|
|
|
possible, it may take longer than you're used to for us to address your issue
|
|
|
|
or pull request.
|
|
|
|
|
|
|
|
So far, we've been doing a larger revision to coincide with [Rust
|
|
|
|
Editions](https://doc.rust-lang.org/edition-guide/). Between those larger
|
|
|
|
revisions, we will only be correcting errors. If your issue or pull request
|
|
|
|
isn't strictly fixing an error, it might sit until the next time that we're
|
|
|
|
working on a large revision: expect on the order of months or years. Thank you
|
|
|
|
for your patience!
|
|
|
|
|
2017-03-26 15:15:19 +00:00
|
|
|
### Translations
|
2017-02-19 02:49:24 +00:00
|
|
|
|
2018-12-12 14:59:58 +00:00
|
|
|
We'd love help translating the book! See the [Translations] label to join in
|
|
|
|
efforts that are currently in progress. Open a new issue to start working on
|
|
|
|
a new language! We're waiting on [mdbook support] for multiple languages
|
|
|
|
before we merge any in, but feel free to start!
|
2017-02-19 01:16:40 +00:00
|
|
|
|
|
|
|
[Translations]: https://github.com/rust-lang/book/issues?q=is%3Aopen+is%3Aissue+label%3ATranslations
|
2023-11-05 21:25:22 +00:00
|
|
|
[mdbook support]: https://github.com/rust-lang/mdBook/issues/5
|
2017-02-19 01:16:40 +00:00
|
|
|
|
2016-12-01 17:54:51 +00:00
|
|
|
## Spellchecking
|
|
|
|
|
2016-12-01 14:33:09 +00:00
|
|
|
To scan source files for spelling errors, you can use the `spellcheck.sh`
|
2021-03-19 14:08:48 +00:00
|
|
|
script available in the `ci` directory. It needs a dictionary of valid words,
|
|
|
|
which is provided in `ci/dictionary.txt`. If the script produces a false
|
2023-05-20 21:42:39 +00:00
|
|
|
positive (say, you used the word `BTreeMap` which the script considers invalid),
|
2021-03-19 14:08:48 +00:00
|
|
|
you need to add this word to `ci/dictionary.txt` (keep the sorted order for
|
|
|
|
consistency).
|