Function into_pointer

Source
pub fn into_pointer<F, P>(function: F) -> *mut c_void
where F: FnOnce() -> Option<NonNull<P>>,
Expand description

Converts a function that returns an Option<NonNull<P>> into a raw C-compatible pointer.

This utility function is used internally to convert Rust’s safe pointer types into C-compatible raw pointers. Returns null_mut() if the function returns None.

§Type Parameters

  • F - A function that returns Option<NonNull<P>>
  • P - The pointer type being converted

§Parameters

  • Function - The function to execute and convert the result

§Returns

A raw C-compatible pointer, or null if the function returns None