4 ms·
How exactly does one decide if scope is lexical or non-lexical? Or more precisely how do you tell compiler?
by Ygg2 12y ago
How exactly does one decide if scope is lexical or non-lexical? Or more precisely how do you tell compiler?
- steveklabnik 12y agoThere is a Drop trait that has one method, drop(). It's like a destructor. It's called for you, but you can also call it yourself. fn foo(x: &something) { // stuff x.drop(); // more stuff, } // if we didn't drop, x gets drop()-ped here If we had non-lexical borrows, after we drop x, we could have it be un-borrowed. currently, x is still considered borrowed until the end of foo(). This is sort of a contrived example, but if you check out the ticket it has better ones. There's also good examples here: http://www.reddit.com/r/rust/comments/2hy06n/a_fresh_look_at_rust_armin_ronachers_thoughts_and/ckxdh5w http://www.reddit.com/r/rust/comments/2hy06n/a_fresh_look_at...