You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
without the return values for the functions being visible to someone reading the rendered book, the text that they experiment with will not compile.
This is confusing for the reader for two reasons
(Almost?) every visible listing prior to this one does build as expected.
The context of this listing specifically asks people to construct an erroneous one to see that code as listed is correct, while the erroneous variant produces an error.
Specifically with regard to point (2), the text that follows the listing contains
If instead we specified use std::fmt::Result and use std::io::Result, we’d
have two Result types in the same scope and Rust wouldn’t know which one we
meant when we used Result. Try it and see what compiler error you get!
The clear implication is that the reader should not expect a compiler error in the listing. So even if there are cases where we want to allow fragmentary listings, listings 7-15 and 7-16 are not such listings.
Suggesting fixes
Simply expose the Ok(()) expressions in the listings 7-15 and 7-16.
Find another example in which either there is no return value or the return value is something simpler for the new user.
I do understand that (1) involves taking up extra visible space. As for (2), I do not know Rust or the standard crates well enough to offer anything specific. (I am only on Chapter 7 of the book.)
Thanks! I've opted to add --snip-- comments that we use to indicate that some code has been elided, and removed the encouragement to try compiling this code.
Listing 7-15 (7-19 on current version of doc.rust-lang.org/book) is
without the return values for the functions being visible to someone reading the rendered book, the text that they experiment with will not compile.
This is confusing for the reader for two reasons
Specifically with regard to point (2), the text that follows the listing contains
The clear implication is that the reader should not expect a compiler error in the listing. So even if there are cases where we want to allow fragmentary listings, listings 7-15 and 7-16 are not such listings.
Suggesting fixes
Ok(())
expressions in the listings 7-15 and 7-16.I do understand that (1) involves taking up extra visible space. As for (2), I do not know Rust or the standard crates well enough to offer anything specific. (I am only on Chapter 7 of the book.)
This issue is prompted by discussion on the forums: https://users.rust-lang.org/t/solved-book-ch07-02-problem-building-example-with-io-result/26595
The text was updated successfully, but these errors were encountered: