pub trait FnPtr: Copy {
// Required methods
fn as_ptr(self) -> NonNull<Code>;
unsafe fn from_ptr(ptr: NonNull<Code>) -> Self;
// Provided method
fn addr(self) -> usize { ... }
}🔬This is a nightly-only experimental API. (
fn_static #148768)Expand description
A common trait implemented by all function pointers.
Required Methods§
Sourcefn as_ptr(self) -> NonNull<Code>
🔬This is a nightly-only experimental API. (fn_static #148768)
fn as_ptr(self) -> NonNull<Code>
fn_static #148768)Returns the function pointer as a NonNull<Code>.
Sourceunsafe fn from_ptr(ptr: NonNull<Code>) -> Self
🔬This is a nightly-only experimental API. (fn_static #148768)
unsafe fn from_ptr(ptr: NonNull<Code>) -> Self
fn_static #148768)Constructs a function pointer from a NonNull pointer.
§Safety
The function pointer must have been obtained
from an FnPtr::as_ptr call from a function
pointer type that is ABI compatible.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".