Recently, I wrote the following:
use std::ptr; fn modify_mut_ret (ptr: &mut T, f: F) -> R where F: FnOnce(T) -> (T,R) { unsafe {