EDIT: After posting this, I found Programming Rust: Fast, Safe Systems Development. I am hesitant to use it now, however, as it is a bit outdated (2017, and Rust has a 2018 edition in which at least something surely changed). If someone could shed some light on this book, that would be great.
I just started trying to learn Rust, but, so far, it has been an incredibly frustrating experience due to the sub-par resources. Specifically, the resources (even the long-form book) tend to not cover essential details while simultaneously having a lot more text to slog through than they need to cover what they do cover. The latter problem may contribute to my perception of the former, as long text to slog through tends to reduce attention to detail so anything that is only briefly mentioned is liable to be missed.
When I learned C++ I originally had a similar experience with the online tutorials, so I did some research and found C++ Primer 5th edition to properly describe the language. That is, it rigorously covers every detail without leaving anything out, and it does so in an order such that you rarely, if ever, need to rely on something that isn't yet explained. In the few cases where it does need to do something like that, it explicitly says so, says where it is properly covered, and gives a simplified explanation to allow the reader to have an internal and precise mental model of what is going on, just one that doesn't cover everything that C++ can do (every program that one writes with that model is correct, but not all correct programs work with that model). Furthermore, it gives exercises after each section that are successfully designed to tease out the subtleties that come with such extreme detail, in order to make sure that the reader truly understands what is going on as opposed to just being able to usually write correct code and blindly throw words at search engines when something is wrong.
Some examples of the essential information that the long form leaves out are:
- value/reference semantics when calling functions aren't mentioned at all in the function or variable sections of chapter 3
- multiple files aren't anywhere as far as I can tell¹
std::io::Stringalso isn't anywhere as far as I can tell¹
println!'s flushing behavior (I tried
print!and was suprised when it didn't flush) isn't covered with
- if statement comparisons with the
std::io::Stringobject isn't in the if statement tutorial, even after introducing the
- Why doesn't
Stringfollow the snake case standard?
The failure of Rust's book to do what C++ Primer does leads to numerous issues. For example, when I wrote the fibbonacci example, I wanted it to loop until the user writes "quit," and then end the program. When I wrote
if user_input == "quit", however, the condition always evaluated to false and CLion's Rust plugin complained about a syntax error. From CLion's syntax error, I was able to find out about
std::io::String and I at least have something to go on to research to fix the issue, but, with decent learning materials I wouldn't have to as even the temporary model to cover strings before classes (if this is even the right order for Rust) would always produce correct programs, or it would be made explicit that string comparisons are impossible until a particular chapter so I would simply wait until I got there.
So, I ask, are there any resources for learning Rust that have the strengths of C++ Primer, so I am not constantly frustrated from running into brick walls of stuff that the official long-form book just decided to leave unknown?
1: "as far as I can tell," in this context, means that I don't remember reading anything with how far I got that either covered it or explicitly said that it would be covered later (even without a temporary mental model) and none of the section titles on the left of the online book seem relevant.