Skip to content

Commit

Permalink
Merge pull request #795 from yizeyi18/main
Browse files Browse the repository at this point in the history
`listings/`: synchonize with english version
  • Loading branch information
KaiserY authored Jun 6, 2024
2 parents 93075e4 + c8a74b3 commit d00679f
Show file tree
Hide file tree
Showing 1,986 changed files with 722 additions and 3,253 deletions.
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-01/Cargo.lock
100755 → 100644
Empty file.
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-01/Cargo.toml
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion listings/ch02-guessing-game-tutorial/listing-02-01/src/main.rs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() {
// ANCHOR_END: expect

// ANCHOR: print_guess
println!("You guessed: {guess}");
println!("You guessed: {}", guess);
// ANCHOR_END: print_guess
}
// ANCHOR: all
16 changes: 8 additions & 8 deletions listings/ch02-guessing-game-tutorial/listing-02-02/Cargo.lock
100755 → 100644

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified listings/ch02-guessing-game-tutorial/listing-02-02/Cargo.toml
100755 → 100644
Empty file.
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-02/src/main.rs
100755 → 100644
Empty file.
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-03/Cargo.lock
100755 → 100644
Empty file.
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-03/Cargo.toml
100755 → 100644
Empty file.
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-03/src/main.rs
100755 → 100644
Empty file.
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-04/Cargo.lock
100755 → 100644
Empty file.
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-04/Cargo.toml
100755 → 100644
Empty file.
9 changes: 5 additions & 4 deletions listings/ch02-guessing-game-tutorial/listing-02-04/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ 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
note: method defined here
--> /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/cmp.rs:836: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
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-04/src/main.rs
100755 → 100644
Empty file.
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-05/Cargo.lock
100755 → 100644
Empty file.
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-05/Cargo.toml
100755 → 100644
Empty file.
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-05/src/main.rs
100755 → 100644
Empty file.
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-06/Cargo.lock
100755 → 100644
Empty file.
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-06/Cargo.toml
100755 → 100644
Empty file.
Empty file modified listings/ch02-guessing-game-tutorial/listing-02-06/src/main.rs
100755 → 100644
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$ cargo run
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
Finished dev [unoptimized + debuginfo] target(s) in 1.50s
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.50s
Running `target/debug/guessing_game`
Hello, world!
Empty file.
Empty file.
Empty file.
10 changes: 7 additions & 3 deletions listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ 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
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.59s
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion listings/ch03-common-programming-concepts/listing-03-02/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$ cargo run
Compiling branches v0.1.0 (file:///projects/branches)
Finished dev [unoptimized + debuginfo] target(s) in 0.30s
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.30s
Running `target/debug/branches`
The value of number is: 5
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion listings/ch03-common-programming-concepts/listing-03-04/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$ cargo run
Compiling loops v0.1.0 (file:///projects/loops)
Finished dev [unoptimized + debuginfo] target(s) in 0.32s
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.32s
Running `target/debug/loops`
the value is: 10
the value is: 20
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ 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
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion listings/ch03-common-programming-concepts/no-listing-02-adding-mut/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$ cargo run
Compiling variables v0.1.0 (file:///projects/variables)
Finished dev [unoptimized + debuginfo] target(s) in 0.30s
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.30s
Running `target/debug/variables`
The value of x is: 5
The value of x is: 6
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion listings/ch03-common-programming-concepts/no-listing-03-shadowing/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$ cargo run
Compiling variables v0.1.0 (file:///projects/variables)
Finished dev [unoptimized + debuginfo] target(s) in 0.31s
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s
Running `target/debug/variables`
The value of x in the inner scope is: 12
The value of x is: 6
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ error[E0308]: mismatched types
| ^^^^^^^^^^^^ expected `&str`, found `usize`

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
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion listings/ch03-common-programming-concepts/no-listing-16-functions/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$ cargo run
Compiling functions v0.1.0 (file:///projects/functions)
Finished dev [unoptimized + debuginfo] target(s) in 0.28s
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.28s
Running `target/debug/functions`
Hello, world!
Another function.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$ cargo run
Compiling functions v0.1.0 (file:///projects/functions)
Finished dev [unoptimized + debuginfo] target(s) in 1.21s
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.21s
Running `target/debug/functions`
The value of x is: 5
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$ cargo run
Compiling functions v0.1.0 (file:///projects/functions)
Finished dev [unoptimized + debuginfo] target(s) in 0.31s
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s
Running `target/debug/functions`
The measurement is: 5h
Empty file.
Empty file.
Empty file.
19 changes: 2 additions & 17 deletions listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,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 @@ -35,6 +21,5 @@ 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
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$ cargo run
Compiling functions v0.1.0 (file:///projects/functions)
Finished dev [unoptimized + debuginfo] target(s) in 0.30s
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.30s
Running `target/debug/functions`
The value of x is: 5
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ error[E0308]: mismatched types
| |
| implicitly returns `()` as its body has no tail or `return` expression
8 | x + 1;
| - help: remove this semicolon
| - help: remove this semicolon to return this value

For more information about this error, try `rustc --explain E0308`.
error: could not compile `functions` due to previous error
error: could not compile `functions` (bin "functions") due to 1 previous error
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion listings/ch03-common-programming-concepts/no-listing-26-if-true/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$ cargo run
Compiling branches v0.1.0 (file:///projects/branches)
Finished dev [unoptimized + debuginfo] target(s) in 0.31s
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s
Running `target/debug/branches`
condition was true
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion listings/ch03-common-programming-concepts/no-listing-27-if-false/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$ cargo run
Compiling branches v0.1.0 (file:///projects/branches)
Finished dev [unoptimized + debuginfo] target(s) in 0.31s
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s
Running `target/debug/branches`
condition was false
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ 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
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion listings/ch03-common-programming-concepts/no-listing-30-else-if/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$ cargo run
Compiling branches v0.1.0 (file:///projects/branches)
Finished dev [unoptimized + debuginfo] target(s) in 0.31s
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s
Running `target/debug/branches`
number is divisible by 3
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ 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
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$ cargo run
Compiling loops v0.1.0 (file:///projects/loops)
Finished dev [unoptimized + debuginfo] target(s) in 0.58s
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.58s
Running `target/debug/loops`
count = 0
remaining = 10
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
13 changes: 7 additions & 6 deletions listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
$ 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("Not a number!");
| ^^^^^
| ^^^^^ ----- 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("Not a number!");
| +++
2 | let guess: /* Type */ = "42".parse().expect("Not a number!");
| ++++++++++++

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
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-01/Cargo.lock
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-01/Cargo.toml
100755 → 100644
Empty file.
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-01/src/main.rs
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-02/Cargo.lock
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-02/Cargo.toml
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-02/src/main.rs
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-03/Cargo.lock
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-03/Cargo.toml
100755 → 100644
Empty file.
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-03/src/main.rs
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-04/Cargo.lock
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-04/Cargo.toml
100755 → 100644
Empty file.
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-04/src/main.rs
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-05/Cargo.lock
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-05/Cargo.toml
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-05/src/main.rs
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-06/Cargo.lock
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-06/Cargo.toml
100755 → 100644
Empty file.
11 changes: 7 additions & 4 deletions listings/ch04-understanding-ownership/listing-04-06/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ $ 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(", world");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `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
Empty file modified listings/ch04-understanding-ownership/listing-04-06/src/main.rs
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-07/Cargo.lock
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-07/Cargo.toml
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-07/src/main.rs
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-08/Cargo.lock
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-08/Cargo.toml
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-08/src/main.rs
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-09/Cargo.lock
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-09/Cargo.toml
100755 → 100644
Empty file.
Empty file modified listings/ch04-understanding-ownership/listing-04-09/src/main.rs
100755 → 100644
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
12 changes: 8 additions & 4 deletions listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
$ cargo run
Compiling ownership v0.1.0 (file:///projects/ownership)
error[E0382]: borrow of moved value: `s1`
--> src/main.rs:5:28
--> src/main.rs:5:15
|
2 | let s1 = String::from("hello");
| -- move occurs because `s1` has type `String`, which does not implement the `Copy` trait
3 | let s2 = s1;
| -- value moved here
4 |
5 | println!("{}, world!", s1);
| ^^ value borrowed here after move
5 | println!("{s1}, world!");
| ^^^^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
3 | let s2 = s1.clone();
| ++++++++

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
2 changes: 1 addition & 1 deletion listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/src/main.rs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ fn main() {
let s1 = String::from("hello");
let s2 = s1;

println!("{}, world!", s1);
println!("{s1}, world!");
// ANCHOR_END: here
}
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion listings/ch04-understanding-ownership/no-listing-05-clone/src/main.rs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ fn main() {
let s1 = String::from("hello");
let s2 = s1.clone();

println!("s1 = {}, s2 = {}", s1, s2);
println!("s1 = {s1}, s2 = {s2}");
// ANCHOR_END: here
}
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion listings/ch04-understanding-ownership/no-listing-06-copy/src/main.rs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ fn main() {
let x = 5;
let y = x;

println!("x = {}, y = {}", x, y);
println!("x = {x}, y = {y}");
// ANCHOR_END: here
}
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion listings/ch04-understanding-ownership/no-listing-07-reference/src/main.rs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
let len = calculate_length(&s1);
// ANCHOR_END: here

println!("The length of '{}' is {}.", s1, len);
println!("The length of '{s1}' is {len}.");
}

fn calculate_length(s: &String) -> usize {
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ 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
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ 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
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
18 changes: 15 additions & 3 deletions listings/ch04-understanding-ownership/no-listing-14-dangling-reference/output.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@ 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 {
|

error[E0515]: cannot return reference to local variable `s`
--> src/main.rs:8:5
|
8 | &s
| ^^ returns a reference to data owned by the current function

For more information about this error, try `rustc --explain E0106`.
error: could not compile `ownership` due to previous error
Some errors have detailed explanations: E0106, E0515.
For more information about an error, try `rustc --explain E0106`.
error: could not compile `ownership` (bin "ownership") due to 2 previous errors
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Loading

0 comments on commit d00679f

Please sign in to comment.