trust_me

Crates.iotrust_me
lib.rstrust_me
version0.1.1
sourcesrc
created_at2023-12-07 08:53:35.386507
updated_at2023-12-07 08:59:32.074957
descriptionJust replace unsafe keyword to `safe!` macro. Always trust programmers.
homepagehttps://github.com/Guyutongxue/trust_me_crab
repositoryhttps://github.com/Guyutongxue/trust_me_crab
max_upload_size
id1060817
size2,999
(Guyutongxue)

documentation

https://docs.rs/trust_me

README

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)
    }
}
Commit count: 3

cargo fmt