Skip to content

Commit 94951ed

Browse files
pwbhbaumanj
andauthored
Update src/vec/vec-zsts.md
Co-authored-by: Jon Bauman <[email protected]>
1 parent 18c8a83 commit 94951ed

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/vec/vec-zsts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl<T> DoubleEndedIterator for RawValIter<T> {
215215

216216
And that's it. Iteration works!
217217

218-
One last thing that we need to take into account is that now when our vec gets dropped it deallocates the memory that was allocated during the time our vec was alive. With ZSTs we did not allocate any memory, and infact we never do. So right now we have unsoundness in our code where we still try deallocate a `NonNull::dangling()` ptr that we use to simulate the ZST in our vec, This means that we would cause an undefined behaviour if we try to deallocate something that we never allocated (obviously and for the right reasons). Lets fix tha, in our raw_vec we are going to tweak our Drop trait and check that we deallocate only types that are sized.
218+
One last thing that we need to take into account is that now when our vec gets dropped it deallocates the memory that was allocated during the time our vec was alive. With ZSTs we did not allocate any memory, and in fact we never do. So right now we have unsoundness in our code where we still try deallocate a `NonNull::dangling()` ptr that we use to simulate the ZST in our vec, This means that we would cause undefined behavior if we try to deallocate something that we never allocated (obviously and for the right reasons). To fix that, in our `RawVec` we are going to tweak our `Drop` trait and check that we deallocate only types that are sized.
219219

220220
```rust,ignore
221221
impl<T> Drop for RawVec<T> {

0 commit comments

Comments
 (0)