Skip to content

Commit bed181d

Browse files
woojunromarcoowdrguildoLucaBoschettoiacri
authored
[2024-10-31] Sync fork (#1)
* use OpenSans as fallback font on PRs from forks * Fix typo * Update reference from Rustonomicon to Rust Reference The exercise refers to the "Data layout" section of the Rustonomicon, but now that section claims itself deprecated and redirects to the "Type layout" section of The Rust Reference. * 05_ticket_v2 outro: correct comment on title (mainmatter#179) Characters was meant to be bytes, this was missed in a former refactoring * Change docstring: "when converted to `u8`" Fixed docstring * exercises 02_basic_calculator/04_panics: fix comma splice in panic message * Update 08_overflow.md if you read threw the profile docs it provides 4 profiles. https://doc.rust-lang.org/cargo/reference/profiles.html * chore(ci): re-create book artifacts at the beginning of each month * Update 08_overflow.md Added some context. --------- Co-authored-by: Marco Otte-Witte <[email protected]> Co-authored-by: Simon Morgan <[email protected]> Co-authored-by: Luca Boschetto <[email protected]> Co-authored-by: iacri <[email protected]> Co-authored-by: Henk Oordt <[email protected]> Co-authored-by: Benjamin Tamasi <[email protected]> Co-authored-by: Vincent Ging Ho Yim <[email protected]> Co-authored-by: Manuel Bichler <[email protected]> Co-authored-by: Bartlomiej Dudzik <[email protected]>
1 parent 29a3522 commit bed181d

File tree

8 files changed

+37
-17
lines changed

8 files changed

+37
-17
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
pull_request:
88
branches:
99
- main
10+
workflow_dispatch:
11+
schedule:
12+
# First day of a month
13+
- cron: '0 0 1 * *'
1014

1115
jobs:
1216
build:
@@ -15,17 +19,27 @@ jobs:
1519
- uses: actions/checkout@v4
1620
with:
1721
fetch-depth: 0
18-
- uses: actions/checkout@v4
22+
- name: Get Core Sans
23+
uses: actions/checkout@v4
24+
if: "!github.event.pull_request.head.repo.fork"
1925
with:
2026
fetch-depth: 0
2127
repository: mainmatter/core-sans-a-fonts
2228
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
2329
path: core-sans-a-fonts
24-
- name: Install Fonts
30+
- name: Install Core Sans Font
31+
if: "!github.event.pull_request.head.repo.fork"
2532
run: |
2633
sudo cp -r core-sans-a-fonts/* /usr/local/share/fonts/
2734
sudo fc-cache -f -v
2835
fc-list | grep "Core Sans"
36+
- name: Use Fallback font for fork PRs
37+
if: "github.event.pull_request.head.repo.fork"
38+
run: |
39+
sed -i 's/"BoldFont=CoreSansA65.ttf",//g' book/book.toml
40+
sed -i 's/"ItalicFont=CoreSansA45It.ttf",//g' book/book.toml
41+
sed -i 's/"BoldItalicFont=CoreSansA65It.ttf",//g' book/book.toml
42+
sed -i 's/CoreSansA45.ttf/Open Sans:style=Regular/g' book/book.toml
2943
- uses: actions-rust-lang/setup-rust-toolchain@v1
3044
- name: Install exercise plugin
3145
run: cargo install --path helpers/mdbook-exercise-linker
@@ -35,8 +49,8 @@ jobs:
3549
run: |
3650
cargo install mdbook-pandoc --locked --version 0.7.1
3751
sudo apt-get update
38-
sudo apt-get install -y fonts-noto calibre pdftk
39-
52+
sudo apt-get install -y fonts-noto fonts-open-sans calibre pdftk
53+
sudo fc-cache -f -v
4054
export PANDOC_VERSION=3.3
4155
curl -LsSf https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz | tar zxf -
4256
echo "$PWD/pandoc-${PANDOC_VERSION}/bin" >> $GITHUB_PATH

book/book.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ sansfontoptions = [
4949
]
5050
# You can get these fonts here: https://fonts.google.com/selection?query=noto+color+
5151
monofont = "Noto Sans Mono"
52-
mainfontfallback = ["Noto Color Emoji:mode=harf"]
53-
sansfontfallback = ["Noto Color Emoji:mode=harf"]
52+
mainfontfallback = ["Open Sans"]
53+
sansfontfallback = ["Open Sans"]
5454
monofontfallback = [
5555
"Noto Color Emoji:mode=harf",
5656
]
@@ -90,8 +90,8 @@ sansfontoptions = [
9090
]
9191
# You can get these fonts here: https://fonts.google.com/selection?query=noto+color+
9292
monofont = "Noto Sans Mono"
93-
mainfontfallback = ["Noto Color Emoji:mode=harf"]
94-
sansfontfallback = ["Noto Color Emoji:mode=harf"]
93+
mainfontfallback = ["Open Sans"]
94+
sansfontfallback = ["Open Sans"]
9595
monofontfallback = [
9696
"Noto Color Emoji:mode=harf",
9797
]
@@ -121,8 +121,8 @@ metadata-file = "metadata.yml"
121121
[output.pandoc.profile.html.variables]
122122
# You can get these fonts here: https://fonts.google.com/selection?query=noto+color+
123123
monofont = "Noto Sans Mono"
124-
mainfontfallback = ["Noto Color Emoji:mode=harf"]
125-
sansfontfallback = ["Noto Color Emoji:mode=harf"]
124+
mainfontfallback = ["Open Sans"]
125+
sansfontfallback = ["Open Sans"]
126126
monofontfallback = [
127127
"Noto Color Emoji:mode=harf",
128128
]

book/src/02_basic_calculator/08_overflow.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,18 @@ You may be wondering—what is a profile setting? Let's get into that!
6969
A [**profile**](https://doc.rust-lang.org/cargo/reference/profiles.html) is a set of configuration options that can be
7070
used to customize the way Rust code is compiled.
7171

72-
Cargo provides two built-in profiles: `dev` and `release`.\
72+
Cargo provides 4 built-in profiles: `dev`, `release`, `test`, and `bench`.\
7373
The `dev` profile is used every time you run `cargo build`, `cargo run` or `cargo test`. It's aimed at local
7474
development,
7575
therefore it sacrifices runtime performance in favor of faster compilation times and a better debugging experience.\
7676
The `release` profile, instead, is optimized for runtime performance but incurs longer compilation times. You need
7777
to explicitly request via the `--release` flag—e.g. `cargo build --release` or `cargo run --release`.
78+
The `test` profile is the default profile used by `cargo test`. The `test` profile inherits the settings form the `dev` profile.
79+
The `bench` profile is the default profile used by `cargo bench`. The `bench` profile inherits from the `release` profile.
80+
Use `dev` for iterative development and debugging, `release` for optimized production builds,\
81+
`test` for correctness testing, and `bench` for performance benchmarking.
82+
83+
7884

7985
> "Have you built your project in release mode?" is almost a meme in the Rust community.\
8086
> It refers to developers who are not familiar with Rust and complain about its performance on

exercises/02_basic_calculator/04_panics/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod tests {
1919
// 👇 With the `#[should_panic]` annotation we can assert that we expect the code
2020
// under test to panic. We can also check the panic message by using `expected`.
2121
// This is all part of Rust's built-in test framework!
22-
#[should_panic(expected = "The journey took no time at all, that's impossible!")]
22+
#[should_panic(expected = "The journey took no time at all. That's impossible!")]
2323
fn by_zero() {
2424
speed(0, 10, 0);
2525
}

exercises/02_basic_calculator/10_as_casting/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mod tests {
2323

2424
// You could solve this by using exactly the same expression as above,
2525
// but that would defeat the purpose of the exercise. Instead, use a genuine
26-
// `i8` value that is equivalent to `255` when converted from `u8`.
26+
// `i8` value that is equivalent to `255` when converted to `u8`.
2727
let y: i8 = todo!();
2828

2929
assert_eq!(x, y);

exercises/03_ticket_v1/09_heap/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ mod tests {
2121
// This is a tricky question!
2222
// The "intuitive" answer happens to be the correct answer this time,
2323
// but, in general, the memory layout of structs is a more complex topic.
24-
// If you're curious, check out the "Data layout" section of the Rustonomicon
25-
// https://doc.rust-lang.org/nomicon/data.html for more information.
24+
// If you're curious, check out the "Type layout" section of The Rust Reference
25+
// https://doc.rust-lang.org/reference/type-layout.html for more information.
2626
assert_eq!(size_of::<Ticket>(), todo!());
2727
}
2828
}

exercises/05_ticket_v2/15_outro/src/title.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// TODO: Implement `TryFrom<String>` and `TryFrom<&str>` for the `TicketTitle` type,
2-
// enforcing that the title is not empty and is not longer than 50 characters.
2+
// enforcing that the title is not empty and is not longer than 50 bytes.
33
// Implement the traits required to make the tests pass too.
44

55
pub struct TicketTitle(String);

exercises/07_threads/05_channels/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub enum Command {
77
Insert(todo!()),
88
}
99

10-
// Start the system by spawning the server the thread.
10+
// Start the system by spawning the server thread.
1111
// It returns a `Sender` instance which can then be used
1212
// by one or more clients to interact with the server.
1313
pub fn launch() -> Sender<Command> {

0 commit comments

Comments
 (0)