From a3d51a1e4e0ff0f36754e1f63d8c5746b42a2665 Mon Sep 17 00:00:00 2001 From: 0xEgao Date: Wed, 17 Jun 2026 00:02:24 +0530 Subject: [PATCH] doc: Document NonNull pointer ABI compatibility --- library/core/src/ptr/non_null.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index bafc37469b32f..d0b0b74edff87 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -49,6 +49,10 @@ use crate::{fmt, hash, intrinsics, mem, ptr}; /// /// # Representation /// +/// `NonNull` is guaranteed to be ABI-compatible with `*const T`, +/// `*mut T`, `&T`, `&mut T`, and `Box` for all `T`, but its +/// pointer must not be null. +/// /// Thanks to the [null pointer optimization], /// `NonNull` and `Option>` /// are guaranteed to have the same size and alignment: