From b3f44c1335a0ac5c3db84fdec83e20de87b88252 Mon Sep 17 00:00:00 2001 From: Jonas Tepe Date: Sat, 16 Jan 2016 13:07:46 +0100 Subject: [PATCH 1/3] Semicolon was at wrong place in let statement --- src/doc/nomicon/vec-zsts.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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)) } } From 9c5b296dd36b78cdb4659fb77aec9d4f5462c73d Mon Sep 17 00:00:00 2001 From: Jonas Tepe Date: Sat, 16 Jan 2016 13:13:44 +0100 Subject: [PATCH 2/3] added zst iterator additions to final code --- src/doc/nomicon/vec-final.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/doc/nomicon/vec-final.md b/src/doc/nomicon/vec-final.md index 52c22f65076..d0e5c7b0006 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)) } } From 5c6217865815fda78003001073705df65686c164 Mon Sep 17 00:00:00 2001 From: Jonas Tepe Date: Sat, 16 Jan 2016 20:51:55 +0100 Subject: [PATCH 3/3] Fixed indent from tabs to spaces --- src/doc/nomicon/vec-final.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/doc/nomicon/vec-final.md b/src/doc/nomicon/vec-final.md index d0e5c7b0006..1f4377a7ca3 100644 --- a/src/doc/nomicon/vec-final.md +++ b/src/doc/nomicon/vec-final.md @@ -227,10 +227,10 @@ impl Iterator for RawValIter { unsafe { let result = ptr::read(self.start); self.start = if mem::size_of::() == 0 { - (self.start as usize + 1) as *const _ - } else { - self.start.offset(1) - }; + (self.start as usize + 1) as *const _ + } else { + self.start.offset(1) + }; Some(result) } } @@ -251,10 +251,10 @@ impl DoubleEndedIterator for RawValIter { } else { unsafe { self.end = if mem::size_of::() == 0 { - (self.end as usize - 1) as *const _ - } else { - self.end.offset(-1) - }; + (self.end as usize - 1) as *const _ + } else { + self.end.offset(-1) + }; Some(ptr::read(self.end)) } }