Rawn
Helper of raw pointers cleaning.
BoxRaw
Trait BoxRaw
is default implemented for tuples of mut raw pointers.
Struct BoxRaws
is new type struct wrapping BoxRaw
implemented type.
Use
use ;
// declare a raw pointer
let x: *mut u8 = Box into_raw;
// destruct it with `clean()` method of trait `BoxRaw`
x.clean;
// below code would work, but it's accessing dangling pointer.
// which is already cleaned out.
// rust's miri test would not pass this case.
// BoxRaw is implemented for tuples of mut raw pointers.
// Available tuple size is from 1 to 12.
let a = Box into_raw;
let b = Box into_raw;
let c: = Box new;
let c: *mut = Box into_raw;
let x = ;
x.clean;
// `BoxRaws` is new type struct wrapping a tuple of raw pointers.
// It implements BoxRaw too.
let a = Box into_raw;
let b = Box into_raw;
let raws = new;
raws.clean;
// BoxRaw is only for raw pointers which are declared using `Box::into_raw()`.
// Thus, Using coerced mutable references would make errors.
// This code will panic:
let mut c: = vec!;
let c: *mut = &mut c;
c.clean;