pub trait UnsafeFnPtr: FnPtr {
// Required method
unsafe fn invoke(&self, args: Self::Args) -> Self::Output;
}Expand description
Marker trait for all unsafe function pointer types (unsafe fn / unsafe extern fn).
Required Methods§
Sourceunsafe fn invoke(&self, args: Self::Args) -> Self::Output
unsafe fn invoke(&self, args: Self::Args) -> Self::Output
Invokes the function pointed to with the given args.
§Safety
Calling this function pointer is unsafe because the function may have invariants that must be manually upheld by the caller.
§Examples
unsafe fn add(a: *const i32, b: *const i32) -> i32 { *a + *b }
let f: unsafe fn(*const i32, *const i32) -> i32 = add;
let result = unsafe { f.invoke((&2, &3)) };
assert_eq!(result, 5);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.