File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 5151//!
5252//! # Memory layout
5353//!
54- //! For non-zero-sized values, a [`Vec`] will use the [`Global`] allocator for its allocation. It is
54+ //! For non-zero-sized types, [`Vec`] uses the [`Global`] allocator for its allocation. It is
5555//! valid to convert both ways between a [`Vec`] and a raw pointer allocated with the [`Global`]
56- //! allocator, given that the [`Layout`] used with the allocator is correct for a sequence of
57- //! `capacity` values of the type, and the first `len` values pointed to by the raw pointer are
56+ //! allocator, provided that the [`Layout`] used with the allocator is correct for a sequence of
57+ //! `capacity` elements of the type, and the first `len` values pointed to by the raw pointer are
5858//! valid. More precisely, a `ptr: *mut T` that has been allocated with the [`Global`] allocator
5959//! with [`Layout::array::<T>(capacity)`][Layout::array] may be converted into a vec using
6060//! [`Vec::<T>::from_raw_parts(ptr, len, capacity)`](Vec::from_raw_parts).
6161//! Conversely, the memory backing a `value: *mut T` obtained from [`Vec::<T>::as_mut_ptr`] may be
6262//! deallocated using the [`Global`] allocator with the same layout.
6363//!
64- //! For zero-sized values , the `Vec` pointer has to be non-null and sufficiently aligned. The
65- //! recommended way to build a `Vec` of ZSTs if [`vec!`] cannot be used is to use
64+ //! For zero-sized types (ZSTs) , the `Vec` pointer must be non-null and sufficiently aligned.
65+ //! The recommended way to build a `Vec` of ZSTs if [`vec!`] cannot be used is to use
6666//! [`ptr::NonNull::dangling`].
6767//!
6868//! [`push`]: Vec::push
You can’t perform that action at this time.
0 commit comments