pub trait FnPtr:
PartialEq
+ Eq
+ PartialOrd
+ Ord
+ Hash
+ Pointer
+ Debug
+ Clone
+ Copy
+ Send
+ Sync
+ Unpin
+ UnwindSafe
+ RefUnwindSafe
+ Sized {
type Args;
type Output;
type ArityMarker: Arity;
type SafetyMarker: Safety;
type AbiMarker: Abi;
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<Unsafe>>::F
where Self: AsUnsafe { ... }
unsafe fn as_safe(&self) -> <Self as WithSafety<Safe>>::F
where Self: AsSafe { ... }
unsafe fn with_abi<Abi: Abi>(&self) -> <Self as WithAbi<Abi>>::F
where Self: WithAbi<Abi> { ... }
}Expand description
Marker trait for all function pointers.
Required Associated Constants§
Required Associated Types§
Sourcetype ArityMarker: Arity
type ArityMarker: Arity
Marker type denoting arity
Sourcetype SafetyMarker: Safety
type SafetyMarker: Safety
Marker type denoting safety
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
The given pointer has to point 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
The given pointer has to point to a function of the correct type.
Sourcefn as_unsafe(&self) -> <Self as WithSafety<Unsafe>>::Fwhere
Self: AsUnsafe,
fn as_unsafe(&self) -> <Self as WithSafety<Unsafe>>::Fwhere
Self: AsUnsafe,
Produces an unsafe version of this function pointer.
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.