Skip to content

Commit 26cfd21

Browse files
committed
simplify is_nonoverlapping a bit
1 parent 4cb4013 commit 26cfd21

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/core/src/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2568,7 +2568,7 @@ pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) -
25682568
let size = mem::size_of::<T>()
25692569
.checked_mul(count)
25702570
.expect("is_nonoverlapping: `size_of::<T>() * count` overflows a usize");
2571-
let diff = if src_usize > dst_usize { src_usize - dst_usize } else { dst_usize - src_usize };
2571+
let diff = src_usize.abs_diff(dst_usize);
25722572
// If the absolute distance between the ptrs is at least as big as the size of the buffer,
25732573
// they do not overlap.
25742574
diff >= size

0 commit comments

Comments
 (0)