File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed
Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -370,6 +370,7 @@ impl<T> Vec<T> {
370370 ///
371371 /// * `ptr` needs to have been previously allocated via [`String`]/`Vec<T>`
372372 /// (at least, it's highly likely to be incorrect if it wasn't).
373+ /// * `ptr`'s `T` needs to have the same size and alignment as it was allocated with.
373374 /// * `length` needs to be less than or equal to `capacity`.
374375 /// * `capacity` needs to be the capacity that the pointer was allocated with.
375376 ///
Original file line number Diff line number Diff line change @@ -848,12 +848,12 @@ extern "rust-intrinsic" {
848848 /// // The no-copy, unsafe way, still using transmute, but not UB.
849849 /// // This is equivalent to the original, but safer, and reuses the
850850 /// // same Vec internals. Therefore the new inner type must have the
851- /// // exact same size, and the same or lesser alignment, as the old
852- /// // type. The same caveats exist for this method as transmute, for
851+ /// // exact same size, and the same alignment, as the old type.
852+ /// // The same caveats exist for this method as transmute, for
853853 /// // the original inner type (`&i32`) to the converted inner type
854854 /// // (`Option<&i32>`), so read the nomicon pages linked above.
855855 /// let v_from_raw = unsafe {
856- /// Vec::from_raw_parts(v_orig.as_mut_ptr(),
856+ /// Vec::from_raw_parts(v_orig.as_mut_ptr() as *mut Option<&i32> ,
857857 /// v_orig.len(),
858858 /// v_orig.capacity())
859859 /// };
You can’t perform that action at this time.
0 commit comments