]> git.lizzy.rs Git - rust.git/commitdiff
Refine docs for `RawVec::from_raw_parts(_in)`
authorTim Diekmann <tim.diekmann@3dvision.de>
Wed, 25 Mar 2020 17:44:29 +0000 (18:44 +0100)
committerTim Diekmann <tim.diekmann@3dvision.de>
Thu, 26 Mar 2020 16:13:11 +0000 (17:13 +0100)
src/liballoc/raw_vec.rs

index ba810bf5faf98011fc41d4f384077ffbed8a6861..79dfa7b6b453e68aaf46c9e27321141ac20bf3d4 100644 (file)
@@ -100,10 +100,11 @@ pub fn with_capacity_zeroed(capacity: usize) -> Self {
 
     /// Reconstitutes a `RawVec` from a pointer and capacity.
     ///
-    /// # Undefined Behavior
+    /// # Safety
     ///
     /// The `ptr` must be allocated (on the system heap), and with the given `capacity`.
-    /// The `capacity` cannot exceed `isize::MAX` (only a concern on 32-bit systems).
+    /// The `capacity` cannot exceed `isize::MAX` for sized types. (only a concern on 32-bit
+    /// systems). ZSTs may have a capacity up to `usize::MAX`.
     /// If the `ptr` and `capacity` come from a `RawVec`, then this is guaranteed.
     #[inline]
     pub unsafe fn from_raw_parts(ptr: *mut T, capacity: usize) -> Self {
@@ -160,10 +161,11 @@ fn allocate_in(capacity: usize, init: AllocInit, mut alloc: A) -> Self {
 
     /// Reconstitutes a `RawVec` from a pointer, capacity, and allocator.
     ///
-    /// # Undefined Behavior
+    /// # Safety
     ///
     /// The `ptr` must be allocated (via the given allocator `a`), and with the given `capacity`.
-    /// The `capacity` cannot exceed `isize::MAX` (only a concern on 32-bit systems).
+    /// The `capacity` cannot exceed `isize::MAX` for sized types. (only a concern on 32-bit
+    /// systems). ZSTs may have a capacity up to `usize::MAX`.
     /// If the `ptr` and `capacity` come from a `RawVec` created via `a`, then this is guaranteed.
     #[inline]
     pub unsafe fn from_raw_parts_in(ptr: *mut T, capacity: usize, a: A) -> Self {