diff --git a/src/doc/nomicon/vec-final.md b/src/doc/nomicon/vec-final.md index 52c22f65076..1f4377a7ca3 100644 --- a/src/doc/nomicon/vec-final.md +++ b/src/doc/nomicon/vec-final.md @@ -226,7 +226,11 @@ impl Iterator for RawValIter { } else { unsafe { let result = ptr::read(self.start); - self.start = self.start.offset(1); + self.start = if mem::size_of::() == 0 { + (self.start as usize + 1) as *const _ + } else { + self.start.offset(1) + }; Some(result) } } @@ -246,7 +250,11 @@ impl DoubleEndedIterator for RawValIter { None } else { unsafe { - self.end = self.end.offset(-1); + self.end = if mem::size_of::() == 0 { + (self.end as usize - 1) as *const _ + } else { + self.end.offset(-1) + }; Some(ptr::read(self.end)) } } diff --git a/src/doc/nomicon/vec-zsts.md b/src/doc/nomicon/vec-zsts.md index fb337a891a8..5f3b2a81364 100644 --- a/src/doc/nomicon/vec-zsts.md +++ b/src/doc/nomicon/vec-zsts.md @@ -140,8 +140,8 @@ impl Iterator for RawValIter { self.start = if mem::size_of::() == 0 { (self.start as usize + 1) as *const _ } else { - self.start.offset(1); - } + self.start.offset(1) + }; Some(result) } } @@ -164,8 +164,8 @@ impl DoubleEndedIterator for RawValIter { self.end = if mem::size_of::() == 0 { (self.end as usize - 1) as *const _ } else { - self.end.offset(-1); - } + self.end.offset(-1) + }; Some(ptr::read(self.end)) } }