Skip to content

Commit d0382d5

Browse files
author
Alex Huszagh
committed
Bug fix for older Rustc versions.
1 parent 5006109 commit d0382d5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ license = "MIT/Apache-2.0"
99
name = "stackvector"
1010
readme = "README.md"
1111
repository = "https://github.com/Alexhuszagh/rust-stackvector"
12-
version = "1.0.7"
12+
version = "1.0.8"
1313
build = "build.rs"
1414

1515
[badges]

src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -554,30 +554,30 @@ impl<A: Array> StackVec<A> {
554554
unsafe {
555555
let old_len = self.len();
556556
assert!(index <= old_len);
557-
let mut ptr = self.as_mut_ptr().add(index);
557+
let mut ptr = self.as_mut_ptr().padd(index);
558558

559559
// Move the trailing elements.
560-
ptr::copy(ptr, ptr.add(lower_size_bound), old_len - index);
560+
ptr::copy(ptr, ptr.padd(lower_size_bound), old_len - index);
561561

562562
// In case the iterator panics, don't double-drop the items we just copied above.
563563
self.set_len(index);
564564

565565
let mut num_added = 0;
566566
for element in iter {
567-
let mut cur = ptr.add(num_added);
567+
let mut cur = ptr.padd(num_added);
568568
if num_added >= lower_size_bound {
569569
// Iterator provided more elements than the hint. Move trailing items again.
570570
assert!(self.len() + 1 <= self.capacity());
571-
ptr = self.as_mut_ptr().add(index);
572-
cur = ptr.add(num_added);
573-
ptr::copy(cur, cur.add(1), old_len - index);
571+
ptr = self.as_mut_ptr().padd(index);
572+
cur = ptr.padd(num_added);
573+
ptr::copy(cur, cur.padd(1), old_len - index);
574574
}
575575
ptr::write(cur, element);
576576
num_added += 1;
577577
}
578578
if num_added < lower_size_bound {
579579
// Iterator provided fewer elements than the hint
580-
ptr::copy(ptr.add(lower_size_bound), ptr.add(num_added), old_len - index);
580+
ptr::copy(ptr.padd(lower_size_bound), ptr.padd(num_added), old_len - index);
581581
}
582582

583583
self.set_len(old_len + num_added);

0 commit comments

Comments
 (0)