Skip to content

Commit 8da31d7

Browse files
authored
Change code for into_iter on the RawVec section for consistency/soundness (#302)
1 parent 0c7e5bd commit 8da31d7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/vec/vec-raw.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ impl<T> Vec<T> {
145145
146146
IntoIter {
147147
start: buf.ptr.as_ptr(),
148-
end: buf.ptr.as_ptr().add(len),
148+
end: if buf.cap == 0 {
149+
// can't offset off of a pointer unless it's part of an allocation
150+
buf.ptr.as_ptr()
151+
} else {
152+
buf.ptr.as_ptr().add(len)
153+
},
149154
_buf: buf,
150155
}
151156
}

0 commit comments

Comments
 (0)