Re:The Rust borrow checker from a different perspective
by i_feel_great on Tuesday November 06, 2018 @02:40AM
(#18389099)
How do you get back something owned by something else?
[ Parent
| on HN ]
Re:The Rust borrow checker from a different perspective
by Munksgaard on Tuesday November 06, 2018 @02:52AM
(#18389152)
You don't, unless they pass it to you (as a return value or function argument).
Re:The Rust borrow checker from a different perspective
by alrz on Tuesday November 06, 2018 @05:24AM
(#18389771)
Or if the borrow doesn't outlive the source e.g. if a local goes out of scope.
Re:The Rust borrow checker from a different perspective
by twic on Tuesday November 06, 2018 @08:08AM
(#18390610)
Return it from a method, or store it into a field of an object you already own.
Re:The Rust borrow checker from a different perspective
by i_feel_great on Tuesday November 06, 2018 @06:52AM
(#18390141)
I don't see that big a deal. In a language, say Ada, I would pass in an "IN" parameter, which cannot be altered in a procedure (and by default in a function). In other languages I would keep the scope/lifetime extremely small, and just not mutate or leak memory. This is just plain ol' good programming practice IMHO.
Is there another more compelling use case. In concurrent applications perhaps?
Re:The Rust borrow checker from a different perspective
by oconnor663 on Thursday November 08, 2018 @12:29AM
(#18404514)
Yes, being able to pass ownership of a Vec to another thread is important, because otherwise the two threads have to coordinate over when to call its destructor.