simplify is_nonoverlapping a bit
This commit is contained in:
parent
4cb4013464
commit
26cfd211fb
1 changed files with 1 additions and 1 deletions
|
|
@ -2568,7 +2568,7 @@ pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) -
|
|||
let size = mem::size_of::<T>()
|
||||
.checked_mul(count)
|
||||
.expect("is_nonoverlapping: `size_of::<T>() * count` overflows a usize");
|
||||
let diff = if src_usize > dst_usize { src_usize - dst_usize } else { dst_usize - src_usize };
|
||||
let diff = src_usize.abs_diff(dst_usize);
|
||||
// If the absolute distance between the ptrs is at least as big as the size of the buffer,
|
||||
// they do not overlap.
|
||||
diff >= size
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue