Skip to content

Commit 6279d09

Browse files
committed
Make pointer::byte_offset_from more generic
1 parent 1481fd9 commit 6279d09

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

library/core/src/ptr/const_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ impl<T: ?Sized> *const T {
684684
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
685685
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
686686
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
687-
pub const unsafe fn byte_offset_from(self, origin: *const T) -> isize {
687+
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {
688688
// SAFETY: the caller must uphold the safety contract for `offset_from`.
689689
unsafe { self.cast::<u8>().offset_from(origin.cast::<u8>()) }
690690
}

library/core/src/ptr/mut_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ impl<T: ?Sized> *mut T {
861861
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
862862
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
863863
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
864-
pub const unsafe fn byte_offset_from(self, origin: *const T) -> isize {
864+
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {
865865
// SAFETY: the caller must uphold the safety contract for `offset_from`.
866866
unsafe { self.cast::<u8>().offset_from(origin.cast::<u8>()) }
867867
}

0 commit comments

Comments
 (0)