File tree 2 files changed +4
-3
lines changed
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> {
370
370
///
371
371
/// * `ptr` needs to have been previously allocated via [`String`]/`Vec<T>`
372
372
/// (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.
373
374
/// * `length` needs to be less than or equal to `capacity`.
374
375
/// * `capacity` needs to be the capacity that the pointer was allocated with.
375
376
///
Original file line number Diff line number Diff line change @@ -848,12 +848,12 @@ extern "rust-intrinsic" {
848
848
/// // The no-copy, unsafe way, still using transmute, but not UB.
849
849
/// // This is equivalent to the original, but safer, and reuses the
850
850
/// // 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
853
853
/// // the original inner type (`&i32`) to the converted inner type
854
854
/// // (`Option<&i32>`), so read the nomicon pages linked above.
855
855
/// 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> ,
857
857
/// v_orig.len(),
858
858
/// v_orig.capacity())
859
859
/// };
You can’t perform that action at this time.
0 commit comments