Skip to main content

closure_unchecked

Macro closure_unchecked 

Source
macro_rules! closure_unchecked {
    ($closure:expr, $fn_type:ty) => { ... };
}
Expand description

Converts a closure to a FuncPtr.

This macro allows you to use Rust closures as mock implementations in injectorpp by converting them to function pointers.

§Parameters

  • $closure: The closure to convert
  • $fn_type: The explicit function type signature that the closure conforms to

§Safety

This macro uses unsafe code internally and comes with significant safety requirements:

  • The closure’s signature must exactly match the provided function type
  • The closure must not capture any references or variables with lifetimes shorter than the mock’s usage
  • The closure must remain valid for the entire duration it’s used by injectorpp
  • Mismatched function signatures will lead to undefined behavior or memory corruption