Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

> Also btw "borrow checker fighting" is not much of an issue for experienced Rust developers. You quickly get used to how to write code to avoid borrow checker issues. And in general, writing code that way tends to be a good thing anyway.

By copying more?



view as:

By building up design habits that lead to things passing the borrow checker on your first try.

By structuring code appropriately - for example, in a GC-based system you can create new objects from anywhere, but in Rust it tends to make more sense to follow a RAII-style model where you take advantage of scope to simplify lifetime management.

Also, by knowing when and how to use wrappers like RC, Arc, RefCell, Box, etc., and by knowing when and how to use lifetime annotations.

As for copying, you learn when to move, when to copy, when to clone, and when to implement the relevant traits on your types.

It's really not that different from working in a language like C or C++, except that the compiler ensures that you're not making any mistakes.


Legal | privacy