WithSafety

Trait WithSafety 

Source
pub trait WithSafety<Safety: Safety>: FnPtr {
    type F: FnPtr<Args = Self::Args, Output = Self::Output, Safety = Safety, Abi = Self::Abi>;
}
Expand description

Helper trait to change the safety of a function pointer type while preserving its abi, arguments and return type.

This is used by with_safety! under the hood.

§Example

type F = extern "C" fn(i32) -> i32;
type G = <F as WithSafety<safety::Unsafe>>::F;
// `G` is `unsafe extern "C" fn(i32) -> i32`

Required Associated Types§

Source

type F: FnPtr<Args = Self::Args, Output = Self::Output, Safety = Safety, Abi = Self::Abi>

The function pointer type with the requested safety (preserving all other properties).

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.

Implementors§

Source§

impl<Safety: Safety, F: FnPtr + WithSafetyImpl<Safety, Self>> WithSafety<Safety> for F

Source§

type F = <F as WithSafetyImpl<Safety>>::F