TS McNamara (25) [Avatar] Offline
#1
Chapter 3 - Compound Data Structures - is live. It is the end result of a significant rewrites and refactors, so do let me know if there are any issues with flow. The chapter covers a great deal, but I really hope that it's a worthwhile read.
55925 (25) [Avatar] Offline
#2
Listing 3.1
"The compiler won't distinguish between String & File" - better use the word 'and' instead of ampersand, as in Rust context ampersand is used as a symbol, and "String & File" may look like a union type syntax for people coming from different languages, skimming through here.
55925 (25) [Avatar] Offline
#3
3.2 Modeling files with structs
Listing 3.2

Note (4): "We'll use the vec! macro..." AFAIC there is no vec macro in use with "data: Vec::new()"

Note (5): "Accessing field by reference prevents use after move issues" - is not very comprehensible by now.


Box: "The newtype pattern" mentions a tuple again, but we do not know much about tuple until now.

In Listing 3.3 we surprisingly see a struct with parentheses instead of curly braces. This was surprising, and I had to google for it. Would be nice to at least mention the word "tuple struct" so the reader knows that this is not a typo, but again a new concept.


Listing 3.5
Note (7) seems to belong to note (6), as I don't think "save_to.append" allocates the buffer ?

Note (9) end of sentence is missing, so what is the replacement?

Note (10) please use the written word 'and' and not '&' here.


55925 (25) [Avatar] Offline
#4
3.3 Adding methods to a struct with impl
Table 3.1
The table is a bit confusing. While the left column is clear, the right column is insofar irritating, that
a) the following listing 3.6 declares the new Method with only one parameter, and indeed the implementation of the upper left cell, so the upper right cell seems to have an obsolete argument.

b) The lower right call first seems clear, but should refer to the new_with_data method later presented to us in Listing 3.7, to be consistent.


After Listing 3.6, at the top of page 56 is a section enclosed in \\\\\ which seems out of place, or referring to an older version of the listing?

55925 (25) [Avatar] Offline
#5
3.4.1 / 3.4.2 presenting the listing before talking about it
In 3.4.1 Listing 3.8 is referred at page 59, but only presented at page 61, after some text and a flow diagram. It would be nice to first see the code and then get into the discussion about it.

Listing 3.8 Note (5) : "Return true 1 in every n times" - the 1 after true is confusing, should be "Return true once in every n times" to be more clear.


In 3.4.2 again the reader's flow is interrupted, as he has to jump from page 62 to page 63, study the listing, get back to the discussion about it on page 62 which would otherwise not be comprehensible, and then end the section with skipping the now known listing to read the rest on page 64.

55925 (25) [Avatar] Offline
#6
3.5 enums, Listing 3.11 doesn't show use of match
On page 66 the first bullet point states "They work together with Rust's pattern matching capabilities to help you build robust, readable code. This is visible on lines 19-23 of Listing 3.11"

Unfortunately that is not the case. The mentioned lines only show matching parts[0], which is a string, against string literals.

On the other hand, seeing match on events in action would be a valuable topic here.