[][src]Attribute Macro unsafe_fn::safe_body

#[safe_body]

Make the body of an unsafe function not allowed to call unsafe code without adding unsafe blocks

This macro can be applied to a unsafe function so that its body is not considered as an unsafe block

use unsafe_fn::safe_body;

#[safe_body]
unsafe fn add_to_ptr(a_ptr: *const i32, b: i32) -> i32 {
    let a = unsafe { *a_ptr }; // dereference in a unsafe block
    a + b // safe code outside of the unsafe block
}