Here’s a copy of the review I just left for a book I recommend called “Programming Rust” at https://www.safaribooksonline.com/library/view/programming-rust/9781491927274/
If you’re interested in learning Rust (and particularly if you come from a C or C++ background), save yourself a lot of time and get this book. I read most of the 1st and 2nd edition free Rust books written by the Rust team, but those books often left me with more questions than answers.
(Quick: why have two string types, &str and String? If you dig enough, you’ll find that str is non-resizeable and always allocated on the stack, and String is resizeable with a heap-allocated buffer. But that doesn’t answer the question, actually. Why not have String be the only type, but with a small-string-optimization (SSO) to avoid unnecessary heap allocations? I’ve yet to find the answer to this question. And to be fair, so far, I haven’t read the answer to this question in this book either, but the authors do offer a rationale of this as a non-resizable+stack/resizeable+heap pattern that occurs in several places in Rust. This has helped (partially) clarify the motivations for the split(s) for me.)
Just about every page I’ve turned to has filled in background or context around Rust that I haven’t found elsewhere. At least in my case, this is exactly the learning and reference material I’ve been looking for.
Kudos to the authors!
I have no affiliation to the company or the authors; I just want to save others time and perhaps frustration if they’re picking up Rust.
The book does good things like list all Rust types in one place, explains exactly and succinctly when auto-dereference can occur (dot operator’s left operand, index operator’s left operand and both operands of all comparison operators ) and what constraints apply–those kinds of explanations are pure gold. The initial example programs are “hello, world”, a web server, followed by multi-threaded mandelbrot set generator, all in Chapter 1. I’m always appreciative when authors can get to interesting (and fun) examples so quickly.
Some things I found that might be of interest:
- If, like I was, you’re not sure, you can read the entire book online for free for 10 days by signing up for a “Free Trial”. (I did, but ended up buying the book within 20 minutes, because it was already answering so many of my questions).
- I got 59% off the eBook price by using a discount code at the checkout (purchase total came to a very reasonable $21): I did a quick Google search and I think the discount code I used was “WKEFRP”.
- The online format downloads as .pdf, or .mobi (open-source e-reader format–compatible with Kindle app, for example).
I think this book is particularly good for programmers with a C or C++ background, like myself. I’m not sure about what one might expect when coming to Rust from, say, a web development background, but I can definitely vouch for the book if you are coming from C/C++.
Hope that is helpful to someone… Now, back to learning!