Crates.io | trust_me |
lib.rs | trust_me |
version | 0.1.1 |
source | src |
created_at | 2023-12-07 08:53:35.386507 |
updated_at | 2023-12-07 08:59:32.074957 |
description | Just replace unsafe keyword to `safe!` macro. Always trust programmers. |
homepage | https://github.com/Guyutongxue/trust_me_crab |
repository | https://github.com/Guyutongxue/trust_me_crab |
max_upload_size | |
id | 1060817 |
size | 2,999 |
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)
}
}