cognitive-engineering-lab / rust-book

The Rust Programming Language: Experimental Edition
https://rust-book.cs.brown.edu
Other
504 stars 82 forks source link

minor update ~/quizzes/ch18-03-pattern-syntax.toml question 2 context #116

Closed YeungOnion closed 7 months ago

YeungOnion commented 11 months ago

Note: I'm aware that this does not meet the CONTRIBUTING guidelines since this isn't to the text of the book in src/ Other note: I really appreciate this project going beyond what the community has already built within the rust-book. Thanks!


Proposing this minor change in the hint's verbiage for quiz 18-03 question 2 as not all other languages implement type for both element type and length for arrays. This edit makes indication to the array type specifying length.

Would this change be too helpful as a hint? It might be as I'm new and figured it out.

willcrichton commented 11 months ago

I think this hint may be confusing, because an array of tuples of any length would never match the pattern (_, n). So specifying that the array is length one may lead readers to assume that length 0 or >1 would be valid when it is not.

YeungOnion commented 11 months ago

Ah, agreed. I actually had an incorrect expectation related to one of the valid patterns, [(n, ..)] so if there's a change, it should be on a different line.

I expected that the most similar valid pattern would have been, [(n, ..), ..] since I didn't connect array's size into its type. So my question is,

Is the intent to re-specify that array types have length included useful?

If not, I'm happy closing. After all, it's from an earlier chapter.