Skip to content

Commit 759815c

Browse files
committed
run prettier
1 parent 364f920 commit 759815c

File tree

10 files changed

+12153
-981
lines changed

10 files changed

+12153
-981
lines changed

content/lessons/01_introduction/a_taste_of_rust-introductory_slides/A_taste_of_Rust.html

Lines changed: 4556 additions & 545 deletions
Large diffs are not rendered by default.

content/lessons/02_ownership/dont_panic/dont_panic.html

Lines changed: 3805 additions & 224 deletions
Large diffs are not rendered by default.

content/lessons/02_ownership/dont_panic/dont_panic.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn div(dividend: i32, divisor: NonZeroI32) -> i32 {
122122
}
123123
fn main() {
124124
// let quotient = div(2137, 42); // This would not type check, because 42 is not NonZeroI32.
125-
125+
126126
// We have to create a NonZeroI32 instance:
127127
let non_zero_divisor_opt: Option<NonZeroI32> = NonZeroI32::new(42);
128128

@@ -143,13 +143,14 @@ fn main() {
143143

144144
### But wait, we ended up with an `unwrap()` anyway. Did we then improve at all?
145145

146-
Actually, yes. Now, the function (here: `div()`) with some (possibly complex) logic **only accepts** (so that the compiler verifies that in compile-time) valid arguments. This way, the function's code can be simpler (no invalid-input-related error handling). Also, it's easier to convince yourself that your number is nonzero that to make sure that it upholds all guarantees required in the docs of the function containing logic.
146+
Actually, yes. Now, the function (here: `div()`) with some (possibly complex) logic **only accepts** (so that the compiler verifies that in compile-time) valid arguments. This way, the function's code can be simpler (no invalid-input-related error handling). Also, it's easier to convince yourself that your number is nonzero that to make sure that it upholds all guarantees required in the docs of the function containing logic.
147147

148148
---
149149

150150
## To `panic` or not to `panic`
151151

152152
Don't panic:
153+
153154
- if the failure is caused by bad user input - you don't want to open up a highway for DoS attackers, do you?
154155
- if the failure only affects some task and not the program in general, e.g. when the server returned bad data for a request of one of the users; others are unaffected;
155156
- if the failure is recoverable (there is a reasonable action to be done in such situation, e.g. give user the default value when the server can't be queried for the actual value);
@@ -159,7 +160,8 @@ Don't panic:
159160
## To `panic` or not to `panic`
160161

161162
Do panic:
163+
162164
- if the failure is for sure caused by a bug in your code. It makes sense to inform the whole world that you wrote deficient software, by yelling at them. More seriously, this shortens the feedback loop and bugs are fixed earlier, instead of silently damaging production;
163-
- if the failure is not recoverable (there is no hope, the program is broken, *R.I.P.*, only the famous *restart* could help here);
165+
- if the failure is not recoverable (there is no hope, the program is broken, _R.I.P._, only the famous _restart_ could help here);
164166

165-
---
167+
---

content/lessons/02_ownership/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,4 @@ fn main() {
359359

360360
[ordering in Van Binh](https://classroom.github.com/a/prGDl5Xa)
361361

362-
Deadline: 16.10.2024 23:59
362+
Deadline: 16.10.2024 23:59

content/lessons/02_ownership/string_formatting/string_formatting.html

Lines changed: 3763 additions & 172 deletions
Large diffs are not rendered by default.

content/lessons/02_ownership/string_formatting/string_formatting.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn agriculture() {
4747
"Nothing is better than {0} {2}, except for {1} {2},",
4848
num_animals, num_animals + 1, animal_name
4949
);
50-
50+
5151
// Minimal assert.
5252
assert!(num_animals >= 42);
5353
// assert with a custom panic message.
@@ -83,6 +83,7 @@ fn agriculture() {
8383
// ]
8484
}
8585
```
86+
8687
---
8788

8889
### Various ways to panic
@@ -91,10 +92,10 @@ fn agriculture() {
9192
fn panicking_is_fun() {
9293
panic!("A general panic.");
9394
assert!(false, "An assertion failed.");
94-
95+
9596
unimplemented!("This code is not implemented.");
9697
todo!("This code is not YET implemented - it's going to change.");
97-
98+
9899
unreachable!("We should never reach this line of code!");
99100
}
100101
```
@@ -147,4 +148,4 @@ fn agriculture() {
147148
}
148149
```
149150

150-
---
151+
---

content/lessons/03_data_types/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ So how do we handle situations which can fail? That's where the `Result` type co
109109

110110
[Communications](https://classroom.github.com/a/gDraT0lo)
111111

112-
Deadline: 23.10.2024 23:59
112+
Deadline: 23.10.2024 23:59

content/lessons/03_data_types/module_system/module_system.html

Lines changed: 2 additions & 21 deletions
Large diffs are not rendered by default.

content/lessons/03_data_types/module_system/module_system.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,32 @@ my-project
5252

5353
---
5454

55-
## *Lib crates* can be shared
55+
## _Lib crates_ can be shared
5656

57-
- *crates.io* is the main crate repository.
58-
- If you specify a dependency in `Cargo.toml`, it's fetched from `crates.io` automatically by *Cargo*.
59-
- `lib.rs` is the root of a *lib crate*.
57+
- _crates.io_ is the main crate repository.
58+
- If you specify a dependency in `Cargo.toml`, it's fetched from `crates.io` automatically by _Cargo_.
59+
- `lib.rs` is the root of a _lib crate_.
6060

6161
---
6262

63-
## *Binary crates* can be executed
63+
## _Binary crates_ can be executed
6464

6565
- `cargo run` executes the bin crate in your package.
6666
- If you have multiple bin crates, you have to specify which to run:
67-
`cargo run --bin <bin_name>`
67+
`cargo run --bin <bin_name>`
6868
- Each bin crate in a package can import code from the lib crate there.
6969

7070
---
7171

7272
## Modules: grouping related code (& encapsulation)
73+
7374
```rust
7475
mod front_of_house {
7576
mod hosting {
7677
fn add_to_waitlist() {}
7778
fn seat_at_table() {}
7879
}
79-
80+
8081
// Alternatively, this could be located in `serving.rs` file and imported.
8182
mod serving {
8283
fn take_order() {}
@@ -87,6 +88,7 @@ mod front_of_house {
8788
```
8889

8990
---
91+
9092
## Modules: grouping related code (& encapsulation)
9193

9294
```
@@ -105,7 +107,8 @@ crate
105107

106108
## Exports & imports
107109

108-
- exports: using privacy modifier (`pub`, `pub(crate)`, <no modifier>)
110+
- exports: using privacy modifier (`pub`, `pub(crate)`, [no modifier])
111+
109112
```rust
110113
mod some_mod {
111114
struct ModulePublic;
@@ -114,8 +117,10 @@ mod some_mod {
114117
pub struct WorldPublic;
115118
}
116119
```
120+
117121
- imports: using `use` statement
122+
118123
```rust
119124
use some_mod::CratePublic;
120125
pub use some_mod::WorldPublic; // <-- re-export
121-
```
126+
```
Binary file not shown.

0 commit comments

Comments
 (0)