Skip to content

Rustlang Ownership: Visual Analogy

github.com/Lakshmipathi
12 pointsgiis6 comments
On HN

Comments

I appreciate the sentiment for this, but I personally find the art and composition off-putting.

The writing is a bit confusing. What's with the file transfer jargon?

Was this part of a bigger presentation or blog post maybe?

giisOP

Yes, its part of simple introduction to rust beginners presentation where I used this picture to explain ownership concepts.

In that case it makes more sense. It's still kinda confusing on its own, though. Maybe link to the presentation slides directly, or better yet—upload a video of yourself doing the presentation!

I like the pattern where it gives ownership, and the return value returns that ownership. I hadn't really considered that as a valid pattern yet, coming from other languages!

Despite the little cop picture there's no requirement there to 'return ownership'. It's more like saying I'll gives you a doc provided you agree to give me a doc.

It seems that &mut fits better there.

To be slightly pedantic, the comment in the code example labels a clone as a "copy" which is not really correct.

Strings can’t even be copied since they are heap allocated.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.