From 4edc5b8de330246fda0fb06c2a3b50a6f7403edd Mon Sep 17 00:00:00 2001 From: Aaran Xu Date: Sun, 30 Jan 2022 12:12:14 +0800 Subject: [PATCH] Update codes --- .../listing-02-04/output.txt | 31 ++++++++++++++++--- .../no-listing-02-without-expect/output.txt | 3 +- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/listings/ch02-guessing-game-tutorial/listing-02-04/output.txt b/listings/ch02-guessing-game-tutorial/listing-02-04/output.txt index 6ee46be..6149472 100644 --- a/listings/ch02-guessing-game-tutorial/listing-02-04/output.txt +++ b/listings/ch02-guessing-game-tutorial/listing-02-04/output.txt @@ -16,9 +16,30 @@ error[E0308]: mismatched types = note: expected reference `&String` found reference `&{integer}` -error: aborting due to previous error +error[E0283]: type annotations needed for `{integer}` + --> src/main.rs:8:44 + | +8 | let secret_number = rand::thread_rng().gen_range(1..101); + | ------------- ^^^^^^^^^ cannot infer type for type `{integer}` + | | + | consider giving `secret_number` a type + | + = note: multiple `impl`s satisfying `{integer}: SampleUniform` found in the `rand` crate: + - impl SampleUniform for i128; + - impl SampleUniform for i16; + - impl SampleUniform for i32; + - impl SampleUniform for i64; + and 8 more +note: required by a bound in `gen_range` + --> /Users/carolnichols/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.8.3/src/rng.rs:129:12 + | +129 | T: SampleUniform, + | ^^^^^^^^^^^^^ required by this bound in `gen_range` +help: consider specifying the type arguments in the function call + | +8 | let secret_number = rand::thread_rng().gen_range::(1..101); + | ++++++++ -For more information about this error, try `rustc --explain E0308`. -error: could not compile `guessing_game` - -To learn more, run the command again with --verbose. +Some errors have detailed explanations: E0283, E0308. +For more information about an error, try `rustc --explain E0283`. +error: could not compile `guessing_game` due to 2 previous errors diff --git a/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/output.txt b/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/output.txt index c56c889..8095bbd 100644 --- a/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/output.txt +++ b/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/output.txt @@ -9,6 +9,5 @@ warning: unused `Result` that must be used = note: `#[warn(unused_must_use)]` on by default = note: this `Result` may be an `Err` variant, which should be handled -warning: 1 warning emitted - +warning: `guessing_game` (bin "guessing_game") generated 1 warning Finished dev [unoptimized + debuginfo] target(s) in 0.59s