NonNull for *const T

I have C function that return:

extern "C" fn c_func() -> *const T;

What is equivalent of std::ptr::NonNull to hold this type?
c_func can not return NULL so NonNull would be convinient.
But NonNull::new accept *mut T, plus it has mutable methods,
that should not be used, because of c_func return *const T instead of *mut T for reason.

Rust doesn't provide two version of NonNull. It is fine to use it. If you feel the need, you can define a #[repr(transparent)] wrapper.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.