Programming Rust

Errata for Programming Rust

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Safari Books Online
ch4 Ownership
In Rust example after Python and C++ examples, explaining `let t = s;`

This portion should be made clearer, the text reads "So after initializing t, the program’s memory looks like this:" However, the program's memory will never 'look like' anything--as noted in a later paragraph, the program fails to compile. This should be addressed with some comment earlier. Perhaps, after showing the 'equivalent' Rust code, saying something like, "Now, for reasons we will explain for a moment, this code will fail to compile if you're typing it in yourself. However, let's imagine that we could get this code to compile and run..."

Note from the Author or Editor:
The text is okay as it stands; the reader doesn't like the flow we chose. I'll look this over if we do a second edition.

Frederick Kellison-Linn  Nov 22, 2017  Jun 22, 2018
Safari Books Online
Chapter 2: A Tour of Rust
A Concurrent Mandelbrot Program section

let bounds = parse_pair(&args[2], 'X') .expect("error parsing image dimensions"); should be let bounds = parse_pair(&args[2], 'x') .expect("error parsing image dimensions"); i.e. separator character should be lower-case x to match with example command line.

Note from the Author or Editor:
In Chapter 2, the section titled "A Concurrent Mandelbrot Program", the capitalization of the 'x' in the code example is incorrect on Safari, even though it is correct in the HTML on Atlas and in the PDF. It should be lower-case, but on Safari only it is upper-case.

Jai Sharma  Jan 13, 2018 
Safari Books Online
Figure 17-1
UTF-8 Subsection

Figure 17-1. The UTF-8 encoding in the Code Point Represented column, third row the value should be 0xxxxyyyyyyzzzzzz, instead of the current 0xxxyyyyyyzzzzzz which is missing an x.

Jai Sharma  Jan 31, 2018  Jun 22, 2018
Safari Books Online
ch15
first example in "position, rposition, and ExactSizeIterator"

'E' is used, but it appears 'e' was intended. Current (this assertion fails): assert_eq!(text.chars().position(|c| c == 'E'), Some(1)); Expected (this assertion succeeds): assert_eq!(text.chars().position(|c| c == 'e'), Some(1));

Note from the Author or Editor:
Safari is corrupting code examples by capitalizing text at random.

Michael Bolin
Michael Bolin
 
Feb 01, 2018 
Safari Books Online
ch15
second example in "position, rposition, and ExactSizeIterator"

Current. These do not parse because of the capital B. After fixing that, the first assertion still fails because it is a capital E instead of a lowercase one. assert_eq!(bytes.iter().rposition(|&c| c == B'E'), Some(4)); assert_eq!(bytes.iter().rposition(|&c| c == B'X'), Some(0)); Expected (lowercasing, as appropriate, and now these assertions work): assert_eq!(bytes.iter().rposition(|&c| c == b'e'), Some(4)); assert_eq!(bytes.iter().rposition(|&c| c == b'X'), Some(0));

Note from the Author or Editor:
In Chapter 15, the two code examples in the section "position, rposition, and ExactSizeIterator" are incorrect on Safari, but correct in the PDF and MOBI. The letters in single quotes, and the 'b' in front of them should be as follows: 'e', not 'E' 'z', not 'Z' b'e', not B'E' b'X' (this one is correct) But, making Safari accurately reflect the contents of the Atlas HTML should correct this.

Michael Bolin
Michael Bolin
 
Feb 01, 2018 
Safari Books Online
Chapter 3 - Floating Point Section

The "Floating point" section within chapter 3 has a possible error. If the intention of the following statement: assert_eq!(-1.01f64.floor(), -1.0); is supposed to yield true, then the 2nd argument should be -2.0.

Note from the Author or Editor:
Fixed on master.

James Davis  Feb 20, 2018  Jun 22, 2018
Safari Books Online
ch2
Code block for `escape_time`

In the listing of the `escape_time` function, there is a line `z = z*z + c;`. In the previous listings, similar lines were formatted with a space around the asterisk, i.e. as `z = z * z + c;`.

Frederick Kellison-Linn  Nov 20, 2017  Jun 22, 2018
Safari Books Online
ch3 Tuples
after 3rd code snippet

"in Chapter 2, we need to pass" -> "in Chapter 2, we needed to pass"

Frederick Kellison-Linn  Nov 20, 2017  Jun 22, 2018
Safari Books Online
16
Chapter 16 Vect<T> section

let mut buffer = vec![0u8; 1024]; // 1024 zeroed-out bytes The variable name 'buffer' in the above code snippet doesn't match the one in figure 16-1 which uses 'buf' instead.

Note from the Author or Editor:
In Figure 16-1, at the top right, "buf" should be changed to "buffer".

Jai Sharma  Jan 24, 2018  Jun 22, 2018
PDF
Page 55,470
7rd paragraph

"write_bitmap" should be changed to "write_image".

Note from the Author or Editor:
Fixed on master.

Sungmann Cho  Apr 29, 2018  Jun 22, 2018
Printed
Page 74
Caption of Figure 4-2

"A Vec 32 ..." should be "A Vec<32> ...".

Note from the Author or Editor:
We have a fix for this.

Glyn Normington  Jan 18, 2018  Jun 22, 2018
Mobi
Page 85
That's not page 85 (Kindle doesn't give me page numbers), but Kindle location

The book says Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/oreillymedia/programming_rust Going there gives a 404. Searching https://github.com/oreillymedia for "rust" gives no repos.

Note from the Author or Editor:
This is on page xviii of the print book. The URL should be changed to: https://github.com/ProgrammingRust (Note: When this was reported, the URL in the book was broken. Readers would see a 404 Not Found. Now they'll see a README that links to the correct URL, which is not so bad. Still worth fixing.)

Yarrow Angelweed  Dec 03, 2017  Jun 22, 2018
PDF
Page 88
2nd to last paragraph

"i32 with pretensions" should be "u32 with pretensions"

Note from the Author or Editor:
Fixed on master.

Joe Gilray  Mar 04, 2018  Jun 22, 2018
PDF
Page 119
C++ code snippet

File& operator=(const File &rhs) { close(descriptor); descriptor = dup(rhs.descriptor); } The operator must return *this: File& operator=(const File &rhs) { close(descriptor); descriptor = dup(rhs.descriptor); return *this; }

Note from the Author or Editor:
Reader is correct. We will fix in HTML.

Andrei  Feb 08, 2018  Jun 22, 2018
Printed
Page 164
Table in section "Build Profiles"

The Cargo.toml section used for the command line "cargo build" is [profile.dev] instead of [profile.debug]

Note from the Author or Editor:
Fixed on master.

Stefan Achatz  Feb 12, 2018  Jun 22, 2018
Printed
Page 205
3rd paragraph

It says "PartialCmp", while the correct name of the trait is PartialOrd.

Note from the Author or Editor:
"PartialCmp" should be changed to "PartialOrd".

Ulrik Sverdrup (bluss)  Jan 26, 2018  Jun 22, 2018
Printed
Page 206
3rd paragraph

The book says: "There's a problem: a File has to be mut". The type shared-reference-to-File implements Read/Write, so it does not need to be mutable to be used for reading or writing. It is not obvious or elegant, but it works.

Note from the Author or Editor:
The reader is correct, but the information he's citing is so obscure that I don't think this will affect the effectiveness of the explanation in the book in practice. (If you know enough to notice the problem the reader pointed out, you definitely don't need to read that part of the book.) Since fixing this will require a significant rephrasing of the section, we'll leave this for a second edition.

Ulrik Sverdrup (bluss)  Jan 26, 2018  Jun 22, 2018
Printed
Page 228
Figure 10-7

The pattern in fig 10-7 seems to have a typo: "&Point3d { x, y, x }" should be "&Point3d { x, y, z }".

Jussi Kukkonen  Mar 04, 2018  Jun 22, 2018
Printed
Page 261
2nd paragraph

Duplication of word in first sentence: "that that".

Note from the Author or Editor:
Fixed on master.

Andre Richter  Mar 05, 2018  Jun 22, 2018
ePub
Page 268
last paragraph

The statement "All of Rust’s numeric types implement std:: ops:: Neg, for the unary negation operator -;" probably is incorrect. My understanding is that the unary negation operator is implemented only for signed types, and that it is not implemented for the unsigned integer types u8, u16, u32, u64, u128, and usize because these types cannot represent negative numbers.

Note from the Author or Editor:
This is at the top of page 269 in my copy. "All of Rust's numeric types" should read "All of Rust's signed numeric types".

Tom Phinney  Jan 27, 2018  Jun 22, 2018
ePub
Page 269
Code between 1st and 2nd paragraph

In the last line of code, 'assert_eq!(r + &1009, 1729)', it looks like we are in danger of checking equality between references to integer values, i.e. &factorial(6) and &1009, and the integer value 1729. Instead, the '+' operator seems to be able to is deference up to 1 time, to add the referred-to values and return the answer as a value, so that the assert_eq! works with operands of the same type. I don't think the deferencing behaviour of the '+' operator had previously been mentioned in the text. Minor point, but it did take a bit of thinking to figure out. Thanks for a great book!

Duane  Nov 21, 2017  Jun 22, 2018
PDF
Page 273

code fragment where Rhs: ?Sized this does not appear in the previous code. In p.272, we have trait PartialEq<Rhs: ?Sized = Self> { instead.

Note from the Author or Editor:
Fixed on master.

HIDEMOTO NAKADA  Apr 30, 2018  Jun 22, 2018
PDF
Page 354
the first paragraph

'And like collect, you’ll need to specify the return type: the preceding example writes out the type of living and nonliving, and lets type inference choose the right type parameters for the call.' The type of 'nonliving' is not wrote out in the code. I think this is confusing.

Note from the Author or Editor:
Fixed on master.

HIDEMOTO NAKADA  Apr 30, 2018  Jun 22, 2018
PDF
Page 375
Page 375(353) ch15 End of section 'Building Collections: collect and FromIterator'

let args = std::env::args().collect::<String>(); -> let args = std::env::args().collect::<Vec<String>>();

Note from the Author or Editor:
That's right: near the top of page 353, the line that reads let args = std::env::args().collect::<String>(); should read let args = std::env::args().collect::<Vec<String>>();

Yisheng XU  Nov 28, 2017  Jan 05, 2018
PDF
Page 378
Figure 16-5 and Figure 16.6

1. page 379 description of figure 16-6 2. page 378 description of figure 16-5 `dark gray regions are unused` should be `dark blue regions are unused`? and in figure 16-5, the unused regions are not filled with dark blue Also, most figures about memory layout are blue-colored, except figure 11-1

Note from the Author or Editor:
Indeed, the dark and light areas in Figure 16.5 seem incorrect. We'll send you an exact description of what needs to be changed.

Yisheng Xu  Nov 30, 2017  Jun 22, 2018
PDF
Page 378
the last paragraph

'Dark gray regions are unused.' There are no 'dark gray regions' in Fig. 16-5. And, the diagram shown in 16-5 is quite different from typical hash table implementation. I believe some more explanation is required.

HIDEMOTO NAKADA  Apr 30, 2018  Jun 22, 2018
PDF
Page 395
the first paragraph

'These all draw their definitions from Unicode, as shown in Table 17-0.' The table below is missing caption and table number. and I believe the table number 17-0 is strange.

Note from the Author or Editor:
Fixed on master.

HIDEMOTO NAKADA  Apr 30, 2018  Jun 22, 2018
Printed
Page 400
Code snippet above second paragraph from the bottom of the page

let parenthetical = "(".to_string() + string + ")"; will produce: expected &str, found struct `std::string::String` It should instead be: let parenthetical = "(".to_string() + &string + ")";

Note from the Author or Editor:
Fixed on master.

Petros Angelatos  Feb 03, 2018  Jun 22, 2018
PDF
Page 408
in the middle.

'as we did for the `Complex` type earlier in the book:' I could not find the same code in other sections.

Note from the Author or Editor:
Fixed on master.

HIDEMOTO NAKADA  Apr 30, 2018  Jun 22, 2018
PDF
Page 409
the first sentence

'as do the functions like [T]::binary_search.' I seems that binary_search method is not using Borrow Trait. https://doc.rust-lang.org/std/primitive.slice.html#method.binary_search

Note from the Author or Editor:
Fixed on master.

HIDEMOTO NAKADA  Apr 30, 2018  Jun 22, 2018
PDF
Page 410
the last paragraph

"The nub of the problem is that sometimes the return value of `name` should be..." The function name is 'get_name', not 'name'.

Note from the Author or Editor:
Fixed on master.

HIDEMOTO NAKADA  Apr 30, 2018  Jun 22, 2018
PDF
Page 434
4th paragraph

reader.read_to_end returns type of io::Result<usize> rather than io::Result<()>.

Note from the Author or Editor:
The sentence "Returns io::Result<()>." should be changed to: "Returns an `io::Result<usize>`, the number of bytes read."

HoNooD  Jan 22, 2018  Jun 22, 2018
PDF
Page 463
4th paragraph from back

"The closure we passed to spawn has a return type of io::Result<()>. because that’s what process_files returns." The first period should be a comma instead.

HoNooD  Feb 01, 2018  Jun 22, 2018
PDF
Page 490
Title of sub sub section

'Multi-producer Channels Using Mutexes' 'Multi-producer' should be 'Multi-consumer'

Note from the Author or Editor:
Fixed on master.

HIDEMOTO NAKADA  Apr 30, 2018  Jun 22, 2018
PDF
Page 491
figure

The Figure 19-11 is missing caption

Note from the Author or Editor:
Fixed on master.

HIDEMOTO NAKADA  Apr 30, 2018  Jun 22, 2018
PDF
Page 522
Just above Figure 20-4

'This feature supports extending the #[derive] attribute to handle custom traits, as shown in Figure 20-4.' 'custom traits' should be 'custom derives'.

Note from the Author or Editor:
Fixed on master.

HIDEMOTO NAKADA  Apr 30, 2018  Jun 22, 2018
PDF
Page 531
the second to last paragraph

'But the comment above the definition of the Ascii type says, “Nothing in this module permits the introduction of non-ASCII bytes into an Ascii value.” ' I could not find this comment in this book.

Note from the Author or Editor:
Fixed on master.

HIDEMOTO NAKADA  Apr 30, 2018  Jun 22, 2018
PDF
Page 543
the last sentence of the third paragraph

'Rust infers that the reference’s lifetime must be the RefWithFlag’s argument, which is just what we want: that’s the lifetime of the reference we started with.' I could not really understand 'RefWithFlag’s argument'. Do you mean ' RefWithFlag::new''s argument . ?

Note from the Author or Editor:
Fixed on master.

HIDEMOTO NAKADA  Apr 30, 2018  Jun 22, 2018
PDF
Page 543
l. -5

' How should Rust know that any restrictions apply to pab’s lifetime?' 'pab' should be 'ptr_and_bit'.

Note from the Author or Editor:
Fixed on master.

HIDEMOTO NAKADA  Apr 30, 2018  Jun 22, 2018
PDF
Page 543
last line

'If you omit the _marker field, Rust ...' '_marker' should be 'behaves_like'.

Note from the Author or Editor:
Fixed on master.

HIDEMOTO NAKADA  Apr 30, 2018  Jun 22, 2018
PDF
Page 547
Figure 21-2

5 8 in the figure should be 8 5, since they are capacity and length.

HIDEMOTO NAKADA  May 01, 2018  Jun 22, 2018
Mobi
Page 17115
Figure 17-2

(I only used mobi file so I'm not sure the page number in PDF or printed book) In the figure, '寂' is explained like (sabi: rust). But it's wrong. '寂' means lonely. The correct translation of rust is '錆'.

Note from the Author or Editor:
The Japanese character is correct in the PDF and in the HTML. There must be some problem in the production of the MOBI file.

Anonymous  Feb 21, 2018  Jun 22, 2018