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

Without the borrow checker, how should memory be managed? Just never deallocate?




The borrow checker does not deal with ownership, which is what rust’s memory management leverages. The borrow checker validates that borrows (references) are valid aka that they don’t outlive their sources and that exclusive borrows don’t overlap.

The borrow checker does not influence codegen at all.


It would be the same as in any language with manual memory management, you'd simply get a dangling pointer access. The 'move-by-default' semantics of Rust just makes this a lot trickier than in a 'copy-by-default' language though.

It's actually interesting to me that the Rust borrow checker can 'simply' be disabled (e.g. no language- or stdlib-features really depending on the borrow checker pass) - not that it's very useful in practice though.


The same as C++, destructors get called when an object goes out of scope.



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

Search: