#trust #macro #safe #unsafe #programmers #alloc #wrap

trust_me

Just replace unsafe keyword to safe! macro. Always trust programmers.

2 releases

0.1.1 Dec 7, 2023
0.1.0 Dec 7, 2023

#652 in Memory management

Custom license

3KB

Trust me, this is safe!

A macro wrap unsafe keyword into safe! macro. Always trust programmers.

use std::alloc::{alloc, dealloc, Layout};

use trust_me::safe;

fn main() {
    // TRUST ME! THIS IS SAFE!!!
    safe! {
        let layout = Layout::new::<u32>();
        let ptr = alloc(layout);
        *(ptr as *mut u32) = 42;
        dealloc(ptr, layout)
    }
}

No runtime deps