Use add instead of offset to avoid casting to isize.

This commit is contained in:
Hanif Bin Ariffin
2020-10-21 20:50:00 +08:00
parent 4043c58de7
commit 92867bb118
2 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -230,7 +230,7 @@ impl<A> ArrayString<A>
return Err(CapacityError::new(s));
}
unsafe {
let dst = self.xs.ptr_mut().offset(self.len() as isize);
let dst = self.xs.ptr_mut().add(self.len());
let src = s.as_ptr();
ptr::copy_nonoverlapping(src, dst, s.len());
let newl = self.len() + s.len();
@@ -321,8 +321,8 @@ impl<A> ArrayString<A>
let next = idx + ch.len_utf8();
let len = self.len();
unsafe {
ptr::copy(self.xs.ptr().offset(next as isize),
self.xs.ptr_mut().offset(idx as isize),
ptr::copy(self.xs.ptr().add(next),
self.xs.ptr_mut().add(idx),
len - next);
self.set_len(len - (next - idx));
}