From 10ba8d6cfb46242ab1e7f1477532c30d48dd5bdd Mon Sep 17 00:00:00 2001 From: zachmatson <49772082+zachmatson@users.noreply.github.com> Date: Tue, 24 Aug 2021 17:40:47 -0400 Subject: [PATCH] Change code for `into_iter` on the `RawVec` section for consistency/soundness --- src/vec/vec-raw.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vec/vec-raw.md b/src/vec/vec-raw.md index f4421db3..a7d8dbe6 100644 --- a/src/vec/vec-raw.md +++ b/src/vec/vec-raw.md @@ -145,7 +145,12 @@ impl Vec { IntoIter { start: buf.ptr.as_ptr(), - end: buf.ptr.as_ptr().add(len), + end: if buf.cap == 0 { + // can't offset off of a pointer unless it's part of an allocation + buf.ptr.as_ptr() + } else { + buf.ptr.as_ptr().add(len) + }, _buf: buf, } }