Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There 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...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: