File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -505,13 +505,18 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
505505
506506/// Creates a null raw pointer.
507507///
508+ /// This function is equivalent to zero-initializing the pointer:
509+ /// `MaybeUninit::<*const T>::zeroed().assume_init()`.
510+ /// The resulting pointer has the address 0.
511+ ///
508512/// # Examples
509513///
510514/// ```
511515/// use std::ptr;
512516///
513517/// let p: *const i32 = ptr::null();
514518/// assert!(p.is_null());
519+ /// assert_eq!(p as usize, 0); // this pointer has the address 0
515520/// ```
516521#[ inline( always) ]
517522#[ must_use]
@@ -526,13 +531,18 @@ pub const fn null<T: ?Sized + Thin>() -> *const T {
526531
527532/// Creates a null mutable raw pointer.
528533///
534+ /// This function is equivalent to zero-initializing the pointer:
535+ /// `MaybeUninit::<*mut T>::zeroed().assume_init()`.
536+ /// The resulting pointer has the address 0.
537+ ///
529538/// # Examples
530539///
531540/// ```
532541/// use std::ptr;
533542///
534543/// let p: *mut i32 = ptr::null_mut();
535544/// assert!(p.is_null());
545+ /// assert_eq!(p as usize, 0); // this pointer has the address 0
536546/// ```
537547#[ inline( always) ]
538548#[ must_use]
You can’t perform that action at this time.
0 commit comments