Hacker News new | past | comments | ask | show | jobs | submit login

Here is something, that might ease things: https://rufflewind.com/2017-02-15/rust-move-copy-borrow



Reading that, and the little blurb about move and copy semantics below the infographic, it occurred to me that borrowing is actually rather easily described as real like sharing (which is unfortunately already a loaded term in much of CS due to multiprocessing).

When you share something that is not copyable (such as a pen), you give it to the person borrowing it until they return it when done.

When you share something that is copyable (and idea, some software, a joke), you give someone their own copy to do with as they please. There is no return required.

Borrowing, which is from the receiver's perspective, implies returning, while sharing, from the sender's perspective, may or not mat imply a later return of something.

I wonder how much the conceptual baggage of the terminology affects how people learn them.


Okay, that's really cool and does probably the best job I've seen of an overview of &mut and &.

I feel like you could almost build a rust cheat-sheet poster out of this and few other useful syntax visualizations(traits, generic + lifetime syntax, etc).




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: