From c38877a91f3df92d951e1eac3501d442d9035412 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Mon, 24 Feb 2020 14:03:32 +0100 Subject: [PATCH] Fixes hardcoded output Resolves https://github.com/rust-lang/book/issues/2275 --- .../output.txt | 9 +++++++++ src/ch03-03-how-functions-work.md | 15 +-------------- 2 files changed, 10 insertions(+), 14 deletions(-) create mode 100644 listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt diff --git a/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt b/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt new file mode 100644 index 0000000000..548ce3270b --- /dev/null +++ b/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt @@ -0,0 +1,9 @@ +$ cargo run + Compiling functions v0.1.0 (file:///projects/functions) +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 \ No newline at end of file diff --git a/src/ch03-03-how-functions-work.md b/src/ch03-03-how-functions-work.md index 491a69b859..2077ac7f78 100644 --- a/src/ch03-03-how-functions-work.md +++ b/src/ch03-03-how-functions-work.md @@ -137,20 +137,7 @@ to another variable, as the following code tries to do; you’ll get an error: When you run this program, the error you’ll get looks like this: - - -```text -$ cargo run - Compiling functions v0.1.0 (file:///projects/functions) -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 -``` +{{#include ../listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt}} The `let y = 6` statement does not return a value, so there isn’t anything for `x` to bind to. This is different from what happens in other languages, such as