pub trait FnPtr:
PartialEq
+ Eq
+ PartialOrd
+ Ord
+ Hash
+ Pointer
+ Debug
+ Clone
+ Copy
+ Send
+ Sync
+ Unpin
+ UnwindSafe
+ RefUnwindSafe
+ Sized
+ 'static
+ WithSafety<true>
+ WithSafety<false>
+ WithAbi<{ _ }>
+ WithAbi<{ _ }>
+ WithAbi<{ _ }> {
type Args;
type Output;
const ARITY: usize;
const IS_SAFE: bool;
const IS_EXTERN: bool;
const ABI: Abi;
// Required methods
fn as_ptr(&self) -> UntypedFnPtr;
unsafe fn from_ptr(ptr: UntypedFnPtr) -> Self;
// Provided methods
fn addr(&self) -> usize { ... }
unsafe fn from_addr(addr: usize) -> Self { ... }
fn as_unsafe(&self) -> <Self as WithSafety<{ false }>>::F { ... }
unsafe fn as_safe(&self) -> <Self as WithSafety<{ true }>>::F { ... }
unsafe fn with_abi<const ABI: u8>(&self) -> <Self as WithAbi<ABI>>::F
where Self: WithAbi<ABI> { ... }
}Expand description
Marker trait for all function pointers.
Required Associated Constants§
Required Associated Types§
Required Methods§
Sourcefn as_ptr(&self) -> UntypedFnPtr
fn as_ptr(&self) -> UntypedFnPtr
Returns a untyped function pointer for this function.
Sourceunsafe fn from_ptr(ptr: UntypedFnPtr) -> Self
unsafe fn from_ptr(ptr: UntypedFnPtr) -> Self
Constructs an instance from an untyped function pointer.
§Safety
This function is unsafe because it can not check if the argument points to a function of the correct type.
Provided Methods§
Sourceunsafe fn from_addr(addr: usize) -> Self
unsafe fn from_addr(addr: usize) -> Self
Constructs an instance from an address.
§Safety
This function is unsafe because it can not check if the argument points to a function of the correct type.
Sourcefn as_unsafe(&self) -> <Self as WithSafety<{ false }>>::F
fn as_unsafe(&self) -> <Self as WithSafety<{ false }>>::F
Produces an unsafe version of this function pointer.
Sourceunsafe fn as_safe(&self) -> <Self as WithSafety<{ true }>>::F
unsafe fn as_safe(&self) -> <Self as WithSafety<{ true }>>::F
Produces a safe version of this function pointer.
§Safety
Caller must ensure the underlying function is actually safe to call.
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.