bbarker/blog

Rust ownership

bbarker opened this issue · 0 comments

From reni on discord

I think that you just need to understand when to use references and when to used owned values. References are supposed to be used only when the owner (there's always one, unless it's static) wants to let something else borrow the value. Otherwise you just let something else, like a function you call, take ownership of the value.... functions that produce values out of thin air basically never want to keep ownership of the thing unless it's some kind of container...