const INVALID_PTR: *mut i32 = core::mem::align_of::<i32>() as _;
struct Resource {
data: i32,
}
impl Resource {
fn new() -> Self {
Self { data: 1337 }
}
}
impl Drop for Resource {
fn drop(&mut self) {
println!("resource dropped");
}
}
fn main() {
let ex = microseh::try_seh(|| unsafe {
let res = Resource::new();
println!("data: {}", res.data);
INVALID_PTR.read_volatile();
});
if let Err(ex) = ex {
println!("{:?}: {}", ex.address(), ex);
}
}