Convert a `*mut c_void` to a `*mut T`, checking that it is not null, misaligned, or pointing to a region of memory that wraps around the address space.
(value: *mut c_void)
| 41 | /// misaligned, or pointing to a region of memory that wraps around the address |
| 42 | /// space. |
| 43 | pub(crate) fn check_raw_pointer<T>(value: *mut c_void) -> Option<NonNull<T>> { |
| 44 | if (value as usize).checked_add(size_of::<T>()).is_none() |
| 45 | || (value as usize) % align_of::<T>() != 0 |
| 46 | { |
| 47 | return None; |
| 48 | } |
| 49 | |
| 50 | NonNull::new(value.cast()) |
| 51 | } |
| 52 | |
| 53 | /// Create a union value containing a default value in one of its arms. |
| 54 | /// |
nothing calls this directly
no test coverage detected