1
Fork 0

use mem::zeroed to make up ZST values

This commit is contained in:
Ralf Jung 2018-09-16 14:26:27 +02:00
parent 61f0a2b3fd
commit 357c5dacee

View file

@ -2410,8 +2410,8 @@ impl<T> Iterator for IntoIter<T> {
// same pointer.
self.ptr = arith_offset(self.ptr as *const i8, 1) as *mut T;
// Read from a properly aligned pointer to make up a value of this ZST.
Some(ptr::read(NonNull::dangling().as_ptr()))
// Make up a value of this ZST.
Some(mem::zeroed())
} else {
let old = self.ptr;
self.ptr = self.ptr.offset(1);
@ -2450,8 +2450,8 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
// See above for why 'ptr.offset' isn't used
self.end = arith_offset(self.end as *const i8, -1) as *mut T;
// Read from a properly aligned pointer to make up a value of this ZST.
Some(ptr::read(NonNull::dangling().as_ptr()))
// Make up a value of this ZST.
Some(mem::zeroed())
} else {
self.end = self.end.offset(-1);