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 51
51
//!
52
52
//! # Memory layout
53
53
//!
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
55
55
//! 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
58
58
//! valid. More precisely, a `ptr: *mut T` that has been allocated with the [`Global`] allocator
59
59
//! with [`Layout::array::<T>(capacity)`][Layout::array] may be converted into a vec using
60
60
//! [`Vec::<T>::from_raw_parts(ptr, len, capacity)`](Vec::from_raw_parts).
61
61
//! Conversely, the memory backing a `value: *mut T` obtained from [`Vec::<T>::as_mut_ptr`] may be
62
62
//! deallocated using the [`Global`] allocator with the same layout.
63
63
//!
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
66
66
//! [`ptr::NonNull::dangling`].
67
67
//!
68
68
//! [`push`]: Vec::push
You can’t perform that action at this time.
0 commit comments