with_safety

Macro with_safety 

Source
macro_rules! with_safety {
    ( safe, $ty:ty ) => { ... };
    ( unsafe, $ty:ty ) => { ... };
    ( $safety:path, $ty:ty ) => { ... };
    ( $safety:tt, $ty:ty ) => { ... };
    ( @inner $safety:ty, $ty:ty ) => { ... };
}
Expand description

Construct a function-pointer type identical to the given one but using the specified safety.

Accepts either:

  • a Safety marker type (Safe or Unsafe)
  • safety keyword (safe or unsafe).
  • a boolean literal.

ยงExamples

type F = with_safety!(safety::Safe, unsafe extern "C" fn(i32) -> i32);
// `F` is `extern "C" fn(i32) -> i32`

type G = with_safety!(unsafe, fn());
// `G` is `unsafe fn()`