Skip to content

Commit dd5045e

Browse files
RalfJunggnzlbg
andauthored
Apply suggestions from code review
Co-Authored-By: gnzlbg <[email protected]>
1 parent 9196781 commit dd5045e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/libstd/primitive_docs.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,12 @@ mod prim_unit { }
363363
/// *[See also the `std::ptr` module](ptr/index.html).*
364364
///
365365
/// Working with raw pointers in Rust is uncommon, typically limited to a few patterns.
366-
/// Raw pointers can be unaligned or [`null`] when unused. However, when a raw pointer is
366+
/// Raw pointers can be unaligned or [`null`]. However, when a raw pointer is
367367
/// dereferenced (using the `*` operator), it must be non-null and aligned.
368368
///
369369
/// Storing through a raw pointer using `*ptr = data` calls `drop` on the old value, so
370370
/// [`write`] must be used if the type has drop glue and memory is not already
371-
/// initialized---otherwise `drop` would be called on the uninitialized memory.
371+
/// initialized - otherwise `drop` would be called on the uninitialized memory.
372372
///
373373
/// Use the [`null`] and [`null_mut`] functions to create null pointers, and the
374374
/// [`is_null`] method of the `*const T` and `*mut T` types to check for null.
@@ -898,7 +898,10 @@ mod prim_usize { }
898898
/// operators on a value, or by using a `ref` or `ref mut` pattern.
899899
///
900900
/// For those familiar with pointers, a reference is just a pointer that is assumed to be
901-
/// aligned, not null, and pointing to valid (initialized) memory.
901+
/// aligned, not null, and pointing to memory containing a valid value of `T` - for example,
902+
/// `&bool` can only point to an allocation containing the integer values `1` (`true`) or `0`
903+
/// (`false`), but the behavior of creating a `&bool` that points to an allocation containing
904+
/// the value `3` is undefined.
902905
/// In fact, `Option<&T>` has the same memory representation as a
903906
/// nullable but aligned pointer, and can be passed across FFI boundaries as such.
904907
///

0 commit comments

Comments
 (0)