what's the general rule of thumb of where to put the "unsafe" keyword?

27 points ibldzn

if i have to interact with ffi and having to deal with raw pointers, should i make my function like this:

unsafe fn foo() {
    // {rust code}
    // {call to ffi}
    // {rust code}
}

or like this:

fn foo() {
    // {rust code}
    unsafe {
        // {call to ffi}
    }
    // {rust code}
}