Struct rust_examples::memory::UseAfterFreeTest [−][src]
pub struct UseAfterFreeTest;Expand description
This test shows that in safe Rust one cannot compile a code that would result in use after free.
Example
ⓘ
struct Data;
fn use_data(data: Data) {
// <arbitry code using the data>
drop(data) // Exaplicit call to `drop` the data
}
let data = Data;
// Use data once and free them afterwards
use_data(data);
// Use data again after free
use_data(data);