I often felt like "now I understood it!" just to encounter a setback a few days after. But I think it's a matter of practice to get more used to certain things.
Some of my personal "milestones":
- figuring out how the for loop works (e.g. when working on a value vs. working on the reference),
- understanding that self-referential structs are impossible (with safe Rust),
- understanding when to use
Arc
,Rc
,Cell
,RefCell
,Mutex
, etc., - realizing that
fn f(&self) -> &str
actually is a short form forfn f<'a>(&'a self) -> &'a str
(lifetime elision) - learning that borrows can end depending on usage rather than lexical scope (non-lexical lifetimes), which isn't something you need to know in everyday programming, but it did confuse me sometimes when some code works and I was surprised that it does.
Especially when I was beginning working with Rust, I sometimes got so annoyed that I cannot hold a reference to something that's inside a struct from within the same struct. Rc
/ Arc
(and RefCell
/ Mutex
) became my friends then.