Skip to content

Commit ad7de67

Browse files
committed
Refine docs for RawVec::from_raw_parts(_in)
1 parent aae3c52 commit ad7de67

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/liballoc/raw_vec.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ impl<T> RawVec<T, Global> {
100100

101101
/// Reconstitutes a `RawVec` from a pointer and capacity.
102102
///
103-
/// # Undefined Behavior
103+
/// # Safety
104104
///
105105
/// The `ptr` must be allocated (on the system heap), and with the given `capacity`.
106-
/// The `capacity` cannot exceed `isize::MAX` (only a concern on 32-bit systems).
106+
/// The `capacity` cannot exceed `isize::MAX` for sized types. (only a concern on 32-bit
107+
/// systems). ZSTs may have a capacity up to `usize::MAX`.
107108
/// If the `ptr` and `capacity` come from a `RawVec`, then this is guaranteed.
108109
#[inline]
109110
pub unsafe fn from_raw_parts(ptr: *mut T, capacity: usize) -> Self {
@@ -160,10 +161,11 @@ impl<T, A: AllocRef> RawVec<T, A> {
160161

161162
/// Reconstitutes a `RawVec` from a pointer, capacity, and allocator.
162163
///
163-
/// # Undefined Behavior
164+
/// # Safety
164165
///
165166
/// The `ptr` must be allocated (via the given allocator `a`), and with the given `capacity`.
166-
/// The `capacity` cannot exceed `isize::MAX` (only a concern on 32-bit systems).
167+
/// The `capacity` cannot exceed `isize::MAX` for sized types. (only a concern on 32-bit
168+
/// systems). ZSTs may have a capacity up to `usize::MAX`.
167169
/// If the `ptr` and `capacity` come from a `RawVec` created via `a`, then this is guaranteed.
168170
#[inline]
169171
pub unsafe fn from_raw_parts_in(ptr: *mut T, capacity: usize, a: A) -> Self {

0 commit comments

Comments
 (0)