1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-06-26 10:41:01 +02:00

Format all Markdown files with dprint (#1157)

This is the result of running `dprint fmt` after removing `src/` from
the list of excluded directories.

This also reformats the Rust code: we might want to tweak this a bit in
the future since some of the changes removes the hand-formatting. Of
course, this formatting can be seen as a mis-feature, so maybe this is
good overall.

Thanks to mdbook-i18n-helpers 0.2, the POT file is nearly unchanged
after this, meaning that all existing translations remain valid! A few
messages were changed because of stray whitespace characters:

     msgid ""
     "Slices always borrow from another object. In this example, `a` has to remain "
    -"'alive' (in scope) for at least as long as our slice. "
    +"'alive' (in scope) for at least as long as our slice."
     msgstr ""

The formatting is enforced in CI and we will have to see how annoying
this is in practice for the many contributors. If it becomes annoying,
we should look into fixing dprint/check#11 so that `dprint` can annotate
the lines that need fixing directly, then I think we can consider more
strict formatting checks.

I added more customization to `rustfmt.toml`. This is to better emulate
the dense style used in the course:

- `max_width = 85` allows lines to take up the full width available in
our code blocks (when taking margins and the line numbers into account).
- `wrap_comments = true` ensures that we don't show very long comments
in the code examples. I edited some comments to shorten them and avoid
unnecessary line breaks — please trim other unnecessarily long comments
when you see them! Remember we're writing code for slides 😄
- `use_small_heuristics = "Max"` allows for things like struct literals
and if-statements to take up the full line width configured above.

The formatting settings apply to all our Rust code right now — I think
we could improve this with https://github.com/dprint/dprint/issues/711
which lets us add per-directory `dprint` configuration files. However,
the `inherit: true` setting is not yet implemented (as far as I can
tell), so a nested configuration file will have to copy most or all of
the top-level file.
This commit is contained in:
Martin Geisler
2023-12-31 00:15:07 +01:00
committed by GitHub
parent f43e72e0ad
commit c9f66fd425
302 changed files with 3067 additions and 2622 deletions

View File

@ -4,8 +4,8 @@
## Rust Fundamentals
The first four days make up [Rust Fundamentals](../welcome-day-1.md).
The days are fast paced and we cover a lot of ground!
The first four days make up [Rust Fundamentals](../welcome-day-1.md). The days
are fast paced and we cover a lot of ground!
{{%course outline Fundamentals}}
@ -16,14 +16,14 @@ specialized topics:
### Rust in Android
The [Rust in Android](../android.md) deep dive is a half-day course on using Rust for
Android platform development. This includes interoperability with C, C++, and
Java.
The [Rust in Android](../android.md) deep dive is a half-day course on using
Rust for Android platform development. This includes interoperability with C,
C++, and Java.
You will need an [AOSP checkout][1]. Make a checkout of the [course
repository][2] on the same machine and move the `src/android/` directory into
the root of your AOSP checkout. This will ensure that the Android build system
sees the `Android.bp` files in `src/android/`.
You will need an [AOSP checkout][1]. Make a checkout of the
[course repository][2] on the same machine and move the `src/android/` directory
into the root of your AOSP checkout. This will ensure that the Android build
system sees the `Android.bp` files in `src/android/`.
Ensure that `adb sync` works with your emulator or real device and pre-build all
Android examples using `src/android/build_all.sh`. Read the script to see the
@ -35,29 +35,29 @@ commands it runs and make sure they work when you run them by hand.
### Rust in Chromium
The [Rust in Chromium](../chromium.md) deep dive is a half-day course on using
Rust as part of the Chromium browser. It includes using Rust in Chromium's
`gn` build system, bringing in third-party libraries ("crates") and C++
Rust as part of the Chromium browser. It includes using Rust in Chromium's `gn`
build system, bringing in third-party libraries ("crates") and C++
interoperability.
You will need to be able to build Chromium --- a debug, component build is
[recommended](../chromium/setup.md) for speed but any build will work.
Ensure that you can run the Chromium browser that you've built.
[recommended](../chromium/setup.md) for speed but any build will work. Ensure
that you can run the Chromium browser that you've built.
### Bare-Metal Rust
The [Bare-Metal Rust](../bare-metal.md) deep dive is a full day class on using Rust for
bare-metal (embedded) development. Both microcontrollers and application
processors are covered.
The [Bare-Metal Rust](../bare-metal.md) deep dive is a full day class on using
Rust for bare-metal (embedded) development. Both microcontrollers and
application processors are covered.
For the microcontroller part, you will need to buy the [BBC
micro:bit](https://microbit.org/) v2 development board ahead of time. Everybody
will need to install a number of packages as described on the [welcome
page](../bare-metal.md).
For the microcontroller part, you will need to buy the
[BBC micro:bit](https://microbit.org/) v2 development board ahead of time.
Everybody will need to install a number of packages as described on the
[welcome page](../bare-metal.md).
### Concurrency in Rust
The [Concurrency in Rust](../concurrency.md) deep dive is a full day class on classical
as well as `async`/`await` concurrency.
The [Concurrency in Rust](../concurrency.md) deep dive is a full day class on
classical as well as `async`/`await` concurrency.
You will need a fresh crate set up and the dependencies downloaded and ready to
go. You can then copy/paste the examples into `src/main.rs` to experiment with

View File

@ -2,7 +2,7 @@
There are several useful keyboard shortcuts in mdBook:
* <kbd>Arrow-Left</kbd>: Navigate to the previous page.
* <kbd>Arrow-Right</kbd>: Navigate to the next page.
* <kbd>Ctrl + Enter</kbd>: Execute the code sample that has focus.
* <kbd>s</kbd>: Activate the search bar.
- <kbd>Arrow-Left</kbd>: Navigate to the previous page.
- <kbd>Arrow-Right</kbd>: Navigate to the next page.
- <kbd>Ctrl + Enter</kbd>: Execute the code sample that has focus.
- <kbd>s</kbd>: Activate the search bar.

View File

@ -3,11 +3,14 @@
The course has been translated into other languages by a set of wonderful
volunteers:
* [Brazilian Portuguese][pt-BR] by [@rastringer], [@hugojacob], [@joaovicmendes], and [@henrif75].
* [Chinese (Simplified)][zh-CN] by [@suetfei], [@wnghl], [@anlunx], [@kongy], [@noahdragon], [@superwhd], [@SketchK], and [@nodmp].
* [Chinese (Traditional)][zh-TW] by [@hueich], [@victorhsieh], [@mingyc], [@kuanhungchen], and [@johnathan79717].
* [Korean][ko] by [@keispace], [@jiyongp], and [@jooyunghan].
* [Spanish][es] by [@deavid].
- [Brazilian Portuguese][pt-BR] by [@rastringer], [@hugojacob],
[@joaovicmendes], and [@henrif75].
- [Chinese (Simplified)][zh-CN] by [@suetfei], [@wnghl], [@anlunx], [@kongy],
[@noahdragon], [@superwhd], [@SketchK], and [@nodmp].
- [Chinese (Traditional)][zh-TW] by [@hueich], [@victorhsieh], [@mingyc],
[@kuanhungchen], and [@johnathan79717].
- [Korean][ko] by [@keispace], [@jiyongp], and [@jooyunghan].
- [Spanish][es] by [@deavid].
Use the language picker in the top-right corner to switch between languages.
@ -16,10 +19,10 @@ Use the language picker in the top-right corner to switch between languages.
There is a large number of in-progress translations. We link to the most
recently updated translations:
* [Bengali][bn] by [@raselmandol].
* [French][fr] by [@KookaS] and [@vcaen].
* [German][de] by [@Throvn] and [@ronaldfw].
* [Japanese][ja] by [@CoinEZ-JPN] and [@momotaro1105].
- [Bengali][bn] by [@raselmandol].
- [French][fr] by [@KookaS] and [@vcaen].
- [German][de] by [@Throvn] and [@ronaldfw].
- [Japanese][ja] by [@CoinEZ-JPN] and [@momotaro1105].
If you want to help with this effort, please see [our instructions] for how to
get going. Translations are coordinated on the [issue tracker].
@ -33,7 +36,6 @@ get going. Translations are coordinated on the [issue tracker].
[pt-BR]: https://google.github.io/comprehensive-rust/pt-BR/
[zh-CN]: https://google.github.io/comprehensive-rust/zh-CN/
[zh-TW]: https://google.github.io/comprehensive-rust/zh-TW/
[@anlunx]: https://github.com/anlunx
[@CoinEZ-JPN]: https://github.com/CoinEZ
[@deavid]: https://github.com/deavid
@ -62,6 +64,5 @@ get going. Translations are coordinated on the [issue tracker].
[@vcaen]: https://github.com/vcaen
[@victorhsieh]: https://github.com/victorhsieh
[@wnghl]: https://github.com/wnghl
[our instructions]: https://github.com/google/comprehensive-rust/blob/main/TRANSLATIONS.md
[issue tracker]: https://github.com/google/comprehensive-rust/issues/282