> Though it is a matter of explicit over implicit too. If `name()` had a destructor you may want it to be explicitly tied to a scope by dint of being declared in one instead of floating around in a magical hidden variable that's tied to the scope of a different one. So there are reasons for why it may never be made to work that way.
I'm not sure I see what the problem is with this. It seems like it is very intuitive behaviour in this case and exactly what you would expect.
Re:Fighting the Borrow Checker
by Manishearth on Monday January 16, 2017 @05:09PM
(#13413467)
Rust is more explicit about moving and scopes. It's currently very easy to see how long a value will live and where the destructor will run. This somewhat complicates that.
This is similar to vvanders' and steve's comments in https://news.ycombinator.com/item?id=13413084 ; such things lead to a more complicated mental model even if on the surface it looks simpler.
It could, but it doesn't yet. This kind of analysis needs porting borrowck to MIR, which still has to happen. It's too complicated given the current way it works.
Though it is a matter of explicit over implicit too. If `name()` had a destructor you may want it to be explicitly tied to a scope by dint of being declared in one instead of floating around in a magical hidden variable that's tied to the scope of a different one. So there are reasons for why it may never be made to work that way.