Open bgigous opened 1 year ago
@bgigous FYI, there's a fix for this issue in PR #56:
https://github.com/rust-in-action/code/pull/56/files
which was submitted over a year ago, but still hasn't been merged. (I too just ran into this same issue.)
From the "ch5" directory on my machine I've just manually applied the PR fix with:
ewen@basadi:~/misc/src/rust/rust-in-action/code/ch5$ curl -s https://patch-diff.githubusercontent.com/raw/rust-in-action/code/pull/56.patch | patch -p 2
patching file ch5-bit-patterns.rs
ewen@basadi:~/misc/src/rust/rust-in-action/code/ch5$ git diff .
diff --git a/ch5/ch5-bit-patterns.rs b/ch5/ch5-bit-patterns.rs
index 03dab50..dae61fc 100644
--- a/ch5/ch5-bit-patterns.rs
+++ b/ch5/ch5-bit-patterns.rs
@@ -8,5 +8,5 @@ fn main() {
let sixtyfivethousand_535: u16 = 0b1111_1111_1111_1111;
print!("{}, {}, {}, ..., ", zero, one, two);
- println!("{}, {}, {}", sixty5_533, sixty5_534, sixty5_535);
+ println!("{}, {}, {}", sixtyfivethousand_533, sixtyfivethousand_534, sixtyfivethousand_535);
}
ewen@basadi:~/misc/src/rust/rust-in-action/code/ch5$ rustc ch5-bit-patterns.rs
ewen@basadi:~/misc/src/rust/rust-in-action/code/ch5$ ./ch5-bit-patterns
0, 1, 2, ..., 65533, 65534, 65535
ewen@basadi:~/misc/src/rust/rust-in-action/code/ch5$
Ewen
PS: Note that the code printed in the book (at least in the PDF version from November 2022) is also wrong, so appears the code got partially changed to make it more readable, and never tested again. cc @timClicks
PPS: ETA: The same fix is also in PR #80 (https://github.com/rust-in-action/code/pull/80/files), so that's at least 4 people who have run into this same issue with the "obvious typos" in the code in the repo.
The listing defines variables like
sixtyfivethousand_533
, but references non existent variablessixty5_533
and so on.