mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-18 00:00:12 +02:00
Offset from (#705)
This commit is contained in:
+15
@@ -148,3 +148,18 @@ fn panic_does_not_fit(size: usize, nbytes: usize) -> ! {
|
||||
size, nbytes
|
||||
);
|
||||
}
|
||||
|
||||
/// Precondition: dst >= original
|
||||
///
|
||||
/// The following line is equivalent to:
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// self.ptr.as_ptr().offset_from(ptr) as usize;
|
||||
/// ```
|
||||
///
|
||||
/// But due to min rust is 1.39 and it is only stabilized
|
||||
/// in 1.47, we cannot use it.
|
||||
#[inline]
|
||||
fn offset_from(dst: *const u8, original: *const u8) -> usize {
|
||||
dst as usize - original as usize
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user