From d0382d5ef903fc96bdcc08c02e36e6dd2eda11a5 Mon Sep 17 00:00:00 2001 From: Alex Huszagh Date: Thu, 5 Sep 2019 18:21:18 -0500 Subject: [PATCH] Bug fix for older Rustc versions. --- Cargo.toml | 2 +- src/lib.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b705aa6..0fb5a38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT/Apache-2.0" name = "stackvector" readme = "README.md" repository = "https://github.com/Alexhuszagh/rust-stackvector" -version = "1.0.7" +version = "1.0.8" build = "build.rs" [badges] diff --git a/src/lib.rs b/src/lib.rs index 16d29a0..21de1d9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -554,30 +554,30 @@ impl StackVec { unsafe { let old_len = self.len(); assert!(index <= old_len); - let mut ptr = self.as_mut_ptr().add(index); + let mut ptr = self.as_mut_ptr().padd(index); // Move the trailing elements. - ptr::copy(ptr, ptr.add(lower_size_bound), old_len - index); + ptr::copy(ptr, ptr.padd(lower_size_bound), old_len - index); // In case the iterator panics, don't double-drop the items we just copied above. self.set_len(index); let mut num_added = 0; for element in iter { - let mut cur = ptr.add(num_added); + let mut cur = ptr.padd(num_added); if num_added >= lower_size_bound { // Iterator provided more elements than the hint. Move trailing items again. assert!(self.len() + 1 <= self.capacity()); - ptr = self.as_mut_ptr().add(index); - cur = ptr.add(num_added); - ptr::copy(cur, cur.add(1), old_len - index); + ptr = self.as_mut_ptr().padd(index); + cur = ptr.padd(num_added); + ptr::copy(cur, cur.padd(1), old_len - index); } ptr::write(cur, element); num_added += 1; } if num_added < lower_size_bound { // Iterator provided fewer elements than the hint - ptr::copy(ptr.add(lower_size_bound), ptr.add(num_added), old_len - index); + ptr::copy(ptr.padd(lower_size_bound), ptr.padd(num_added), old_len - index); } self.set_len(old_len + num_added);