Re:Announcing Rust 1.23
by steveklabnik on Thursday January 04, 2018 @03:04PM
(#16073573)
Gotcha, thanks. Based on what you know, I'd say pointers and stuff like memory layout are generally going to be where you have issues, and data structures are basically an exercise in applied pointers and memory layout. So you shouldn't feel bad! Regarding what you should do next, reading the last few chapters of the book (19 in particular will be useful for you) would be good; and chapter 20 is a project, which it seems like you are looking for. I can also highly recommend the new O'Reilly book as well.
> I was wondering if I am missing anything
Nope, I think it's just that your experience led you astray.
If I need a linked list in Rust, I... well, I don't ever use linked lists (you can read the book for why). If I had to, I'd use the one in the stdlib.
If I need a graph in Rust, I use petgraph from crates.io.
Basically, other people are good at writing data structures, so I use their work as much as possible. Only if I'm particularly interested in a specific structure, or I require one that doesn't have some implementation out there yet, do I try to write my own.
Of course, at some point you'll want to learn it, but it's just going to be frustrating until it clicks. The less frustrated you are with the rest of Rust when that happens, the less overall frustration you'll have.
> (maybe once I learn unsafe it will be easier?)
That's very possible. Often, you can take a C implementation and translate it into unsafe Rust. Many data structures use unsafe internally, and present a safe interface.
Good luck on your journey! I hope it all makes sense for you soon.
> I was wondering if I am missing anything
Nope, I think it's just that your experience led you astray.
If I need a linked list in Rust, I... well, I don't ever use linked lists (you can read the book for why). If I had to, I'd use the one in the stdlib.
If I need a graph in Rust, I use petgraph from crates.io.
Basically, other people are good at writing data structures, so I use their work as much as possible. Only if I'm particularly interested in a specific structure, or I require one that doesn't have some implementation out there yet, do I try to write my own.
Of course, at some point you'll want to learn it, but it's just going to be frustrating until it clicks. The less frustrated you are with the rest of Rust when that happens, the less overall frustration you'll have.
> (maybe once I learn unsafe it will be easier?)
That's very possible. Often, you can take a C implementation and translate it into unsafe Rust. Many data structures use unsafe internally, and present a safe interface.
Good luck on your journey! I hope it all makes sense for you soon.