Skip to content

Commit

Permalink
Merge pull request #363 from damoasda/master
Browse files Browse the repository at this point in the history
Änderungen im Originalbuch bis zum 19.02.2024 nachziehen
  • Loading branch information
damoasda authored Mar 9, 2024
2 parents 863ad6b + b4878db commit daafd0f
Show file tree
Hide file tree
Showing 47 changed files with 333 additions and 265 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Das Buch „Die Programmiersprache Rust“ ist eine deutsche Gemeinschafts-Übersetzung
des [offiziellen Rust-Buchs][rustbook-en].
Es enthält alle Änderungen des englischen Originals bis einschließlich zum **09.11.2023**.
Es enthält alle Änderungen des englischen Originals bis einschließlich zum **19.02.2024**.

## [📖 > Hier online lesen < 📖][rustbook-de]

Expand Down
19 changes: 11 additions & 8 deletions src/ch02-00-guessing-game-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,16 @@ warning: unused `Result` that must be used
--> src/main.rs:10:5
|
10 | io::stdin().read_line(&mut guess);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_must_use)]` on by default
= note: this `Result` may be an `Err` variant, which should be handled
= note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
|
10 | let _ = io::stdin().read_line(&mut guess);
| +++++++

warning: `guessing_game` (bin "guessing_game") generated 1 warning

Finished dev [unoptimized + debuginfo] target(s) in 0.59s
```

Expand Down Expand Up @@ -835,17 +838,17 @@ error[E0308]: mismatched types
--> src/main.rs:22:21
|
22 | match guess.cmp(&secret_number) {
| --- ^^^^^^^^^^^^^^ expected struct `String`, found integer
| --- ^^^^^^^^^^^^^^ expected `&String`, found `&{integer}`
| |
| arguments to this function are incorrect
| arguments to this method are incorrect
|
= note: expected reference `&String`
found reference `&{integer}`
note: associated function defined here
--> /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/cmp.rs:783:8
note: method defined here
--> /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/cmp.rs:814:8

For more information about this error, try `rustc --explain E0308`.
error: could not compile `guessing_game` due to previous error
error: could not compile `guessing_game` (bin "guessing_game") due to 1 previous error
```

Die Kernbotschaft des Fehlers besagt, dass es *nicht übereinstimmende Typen*
Expand Down
10 changes: 8 additions & 2 deletions src/ch03-01-variables-and-mutability.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ error[E0384]: cannot assign twice to immutable variable `x`
| ^^^^^ cannot assign twice to immutable variable

For more information about this error, try `rustc --explain E0384`.
error: could not compile `variables` due to previous error
error: could not compile `variables` (bin "variables") due to 1 previous error
```

Dieses Beispiel zeigt, wie der Compiler dir hilft, Fehler in deinen Programmen
Expand Down Expand Up @@ -258,9 +258,15 @@ error[E0308]: mismatched types
| ----- expected due to this value
3 | spaces = spaces.len();
| ^^^^^^^^^^^^ expected `&str`, found `usize`
|
help: try removing the method call
|
3 - spaces = spaces.len();
3 + spaces = spaces;
|

For more information about this error, try `rustc --explain E0308`.
error: could not compile `variables` due to previous error
error: could not compile `variables` (bin "variables") due to 1 previous error
```

Nachdem wir nun untersucht haben, wie Variablen funktionieren, wollen wir uns
Expand Down
17 changes: 10 additions & 7 deletions src/ch03-02-data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ zu wissen welchen Typ wir verwenden wollen:
```console
$ cargo build
Compiling no_type_annotations v0.1.0 (file:///projects/no_type_annotations)
error[E0282]: type annotations needed
error[E0284]: type annotations needed
--> src/main.rs:2:9
|
2 | let guess = "42".parse().expect("Keine Zahl!");
| ^^^^^
| ^^^^^ ----- type must be known at this point
|
= note: cannot satisfy `<_ as FromStr>::Err == _`
help: consider giving `guess` an explicit type
|
2 | let guess: _ = "42".parse().expect("Keine Zahl!");
| +++
2 | let guess: /* Type */ = "42".parse().expect("Keine Zahl!");
| ++++++++++++

For more information about this error, try `rustc --explain E0282`.
error: could not compile `no_type_annotations` due to previous error
For more information about this error, try `rustc --explain E0284`.
error: could not compile `no_type_annotations` (bin "no_type_annotations") due to 1 previous error
```

Für andere Datentypen wirst du andere Typ-Annotationen sehen.
Expand Down Expand Up @@ -460,9 +461,11 @@ Zahl hinter dem Ende des Arrays eingibst, z.B. `10`, erhältst du eine Ausgabe
wie diese:

```text
thread 'main' panicked at 'index out of bounds: the len is 5 but the index is 10', src/main.rs:19:19
thread 'main' panicked at src/main.rs:19:19:
index out of bounds: the len is 5 but the index is 10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

Das Programm führte zu einem *Laufzeitfehler* an der Stelle, an der ein
ungültiger Wert in der Index-Operation verwendet wurde. Das Programm wurde mit
einer Fehlermeldung beendet und hat die abschließende `println!`-Anweisung
Expand Down
25 changes: 4 additions & 21 deletions src/ch03-03-how-functions-work.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ einen Fehler erhalten:
fn main() {
let x = (let y = 6);
}
```

Wenn du dieses Programm ausführst, wirst du in etwa folgenden Fehler erhalten:
Expand All @@ -194,22 +193,8 @@ error: expected expression, found `let` statement
|
2 | let x = (let y = 6);
| ^^^

error: expected expression, found statement (`let`)
--> src/main.rs:2:14
|
2 | let x = (let y = 6);
| ^^^^^^^^^
|
= note: variable declaration using `let` is a statement

error[E0658]: `let` expressions in this position are unstable
--> src/main.rs:2:14
|
2 | let x = (let y = 6);
| ^^^^^^^^^
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= note: only supported directly in conditions of `if` and `while` expressions

warning: unnecessary parentheses around assigned value
--> src/main.rs:2:13
Expand All @@ -224,9 +209,8 @@ help: remove these parentheses
2 + let x = let y = 6;
|

For more information about this error, try `rustc --explain E0658`.
warning: `functions` (bin "functions") generated 1 warning
error: could not compile `functions` due to 3 previous errors; 1 warning emitted
error: could not compile `functions` (bin "functions") due to 1 previous error; 1 warning emitted
```

Die Anweisung `let y = 6` gibt keinen Wert zurück, also gibt es für `x` nichts,
Expand Down Expand Up @@ -374,11 +358,10 @@ error[E0308]: mismatched types
| |
| implicitly returns `()` as its body has no tail or `return` expression
8 | x + 1;
| - help: consider removing this semicolon
| - help: remove this semicolon to return this value

For more information about this error, try `rustc --explain E0308`.
warning: `functions` (bin "functions") generated 1 warning
error: could not compile `functions` due to 2 previous errors; 1 warning emitted
error: could not compile `functions` (bin "functions") due to 1 previous error
```

Die Hauptfehlermeldung `mismatched types` offenbart das Kernproblem dieses
Expand Down
4 changes: 2 additions & 2 deletions src/ch03-05-control-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ error[E0308]: mismatched types
| ^^^^^^ expected `bool`, found integer

For more information about this error, try `rustc --explain E0308`.
error: could not compile `branches` due to previous error
error: could not compile `branches` (bin "branches") due to 1 previous error
```

Der Fehler gibt an, dass Rust ein `bool` erwartet, aber eine ganze Zahl
Expand Down Expand Up @@ -252,7 +252,7 @@ error[E0308]: `if` and `else` have incompatible types
| expected because of this

For more information about this error, try `rustc --explain E0308`.
error: could not compile `branches` due to previous error
error: could not compile `branches` (bin "branches") due to 1 previous error
```

Der Ausdruck im `if`-Block wird zu einer ganzen Zahl und der Ausdruck im
Expand Down
2 changes: 1 addition & 1 deletion src/ch04-01-what-is-ownership.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ help: consider cloning the value if the performance cost is acceptable
| ++++++++

For more information about this error, try `rustc --explain E0382`.
error: could not compile `ownership` due to previous error
error: could not compile `ownership` (bin "ownership") due to 1 previous error
```

Wenn du beim Arbeiten mit anderen Sprachen schon mal die Begriffe *flache
Expand Down
24 changes: 16 additions & 8 deletions src/ch04-02-references-and-borrowing.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,16 @@ $ cargo run
error[E0596]: cannot borrow `*some_string` as mutable, as it is behind a `&` reference
--> src/main.rs:8:5
|
7 | fn change(some_string: &String) {
| ------- help: consider changing this to be a mutable reference: `&mut String`
8 | some_string.push_str(" Welt");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `some_string` is a `&` reference, so the data it refers to cannot be borrowed as mutable
| ^^^^^^^^^^^ `some_string` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
help: consider changing this to be a mutable reference
|
7 | fn change(some_string: &mut String) {
| +++

For more information about this error, try `rustc --explain E0596`.
error: could not compile `ownership` due to previous error
error: could not compile `ownership` (bin "ownership") due to 1 previous error
```

So wie Variablen standardmäßig unveränderbar sind, so sind auch Referenzen
Expand Down Expand Up @@ -202,7 +205,7 @@ error[E0499]: cannot borrow `s` as mutable more than once at a time
| -- first borrow later used here

For more information about this error, try `rustc --explain E0499`.
error: could not compile `ownership` due to previous error
error: could not compile `ownership` (bin "ownership") due to 1 previous error
```

Dieser Fehler besagt, dass dieser Code ungültig ist, weil wir `s` nicht mehr
Expand Down Expand Up @@ -276,7 +279,7 @@ error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immuta
| -- immutable borrow later used here

For more information about this error, try `rustc --explain E0502`.
error: could not compile `ownership` due to previous error
error: could not compile `ownership` (bin "ownership") due to 1 previous error
```

Puh! Wir können auch keine veränderbaren Referenzen verwenden, solange wir eine
Expand Down Expand Up @@ -358,13 +361,18 @@ error[E0106]: missing lifetime specifier
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
5 | fn dangle() -> &'static String {
| +++++++
help: instead, you are more likely to want to return an owned value
|
5 - fn dangle() -> &String {
5 + fn dangle() -> String {
|

For more information about this error, try `rustc --explain E0106`.
error: could not compile `ownership` due to previous error
error: could not compile `ownership` (bin "ownership") due to 1 previous error
```

Diese Fehlermeldung bezieht sich auf eine Funktionalität, die wir noch nicht
Expand Down
2 changes: 1 addition & 1 deletion src/ch04-03-slices.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immuta
| ---- immutable borrow later used here

For more information about this error, try `rustc --explain E0502`.
error: could not compile `ownership` due to previous error
error: could not compile `ownership` (bin "ownership") due to 1 previous error
```

Erinnere dich an die Ausleihregeln, durch die wir, wenn wir eine
Expand Down
2 changes: 1 addition & 1 deletion src/ch05-01-defining-structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ für jeden Typ implementiert, auch für unit-ähnliche Strukturen.
> |
>
> For more information about this error, try `rustc --explain E0106`.
> error: could not compile `structs` due to 2 previous errors
> error: could not compile `structs` (bin "structs") due to 2 previous errors
> ```
>
> In Kapitel 10 werden wir klären, wie man diese Fehler behebt und Referenzen
Expand Down
5 changes: 3 additions & 2 deletions src/ch05-02-example-structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ Wenn wir diesen Code kompilieren, erhalten wir folgende Fehlermeldung:
```text
error[E0277]: `Rectangle` doesn't implement `std::fmt::Display`
```

Das Makro `println!` kann diverse Formatierungen vornehmen. Die geschweiften
Klammern weisen `println!` an, die Formatierung `Display` zu verwenden, bei der
die Ausgabe direkt für den Endbenutzer bestimmt ist. Die primitiven Typen, die
Expand Down Expand Up @@ -343,8 +344,8 @@ $ cargo run
Compiling rectangles v0.1.0 (file:///projects/rectangles)
Finished dev [unoptimized + debuginfo] target(s) in 0.61s
Running `target/debug/rectangles`
[src/main.rs:10] 30 * scale = 60
[src/main.rs:14] &rect1 = Rectangle {
[src/main.rs:10:16] 30 * scale = 60
[src/main.rs:14:5] &rect1 = Rectangle {
width: 60,
height: 50,
}
Expand Down
6 changes: 3 additions & 3 deletions src/ch06-01-defining-an-enum.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,13 @@ error[E0277]: cannot add `Option<i8>` to `i8`
|
= help: the trait `Add<Option<i8>>` is not implemented for `i8`
= help: the following other types implement trait `Add<Rhs>`:
<i8 as Add>
<i8 as Add<&i8>>
<&'a i8 as Add<i8>>
<&i8 as Add<&i8>>
<i8 as Add<&i8>>
<i8 as Add>

For more information about this error, try `rustc --explain E0277`.
error: could not compile `enums` due to previous error
error: could not compile `enums` (bin "enums") due to 1 previous error
```

Stark! Tatsächlich bedeutet diese Fehlermeldung, dass Rust nicht versteht, wie
Expand Down
8 changes: 4 additions & 4 deletions src/ch06-02-match.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@ error[E0004]: non-exhaustive patterns: `None` not covered
| ^ pattern `None` not covered
|
note: `Option<i32>` defined here
--> /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/option.rs:518:1
--> /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/option.rs:570:1
::: /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/option.rs:574:5
|
= note:
/rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/option.rs:522:5: not covered
= note: not covered
= note: the matched value is of type `Option<i32>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
Expand All @@ -296,7 +296,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit
|

For more information about this error, try `rustc --explain E0004`.
error: could not compile `enums` due to previous error
error: could not compile `enums` (bin "enums") due to 1 previous error
```

Rust weiß, dass wir nicht alle möglichen Fälle abgedeckt haben, und es weiß
Expand Down
12 changes: 8 additions & 4 deletions src/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ error[E0603]: module `hosting` is private
--> src/lib.rs:9:28
|
9 | crate::front_of_house::hosting::add_to_waitlist();
| ^^^^^^^ private module
| ^^^^^^^ --------------- function `add_to_waitlist` is not publicly re-exported
| |
| private module
|
note: the module `hosting` is defined here
--> src/lib.rs:2:5
Expand All @@ -108,7 +110,9 @@ error[E0603]: module `hosting` is private
--> src/lib.rs:12:21
|
12 | front_of_house::hosting::add_to_waitlist();
| ^^^^^^^ private module
| ^^^^^^^ --------------- function `add_to_waitlist` is not publicly re-exported
| |
| private module
|
note: the module `hosting` is defined here
--> src/lib.rs:2:5
Expand All @@ -117,7 +121,7 @@ note: the module `hosting` is defined here
| ^^^^^^^^^^^

For more information about this error, try `rustc --explain E0603`.
error: could not compile `restaurant` due to 2 previous errors
error: could not compile `restaurant` (lib) due to 2 previous errors
```

<span class="caption">Codeblock 7-4: Kompilierfehler im Code in Codeblock
Expand Down Expand Up @@ -208,7 +212,7 @@ note: the function `add_to_waitlist` is defined here
| ^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0603`.
error: could not compile `restaurant` due to 2 previous errors
error: could not compile `restaurant` (lib) due to 2 previous errors
```

<span class="caption">Codeblock 7-6: Kompilierfehler im Code in Codeblock
Expand Down
Loading

0 comments on commit daafd0f

Please sign in to comment.