3 ms·
In rust, can't you just use a {} block to force the scope limitation? (I've just browsed the rust docs, never written anythign in it) fn do_stuff() {
by deckiedan 11y ago
In rust, can't you just use a {} block to force the scope limitation?
(I've just browsed the rust docs, never written anythign in it)
fn do_stuff() {
// already inside a function!
{
// allocate here...
let x = Giraffe();
}
// should be deallocated by now. right?
}
- Animats 11y agoYou can certainly limit scope in Rust. That's not the problem, though. The problem is, what if something goes wrong in Giraffe's destructor? Like maybe the remote procedure call to Zoo fails.