mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-15 00:00:18 +02:00
Offset from (#705)
This commit is contained in:
+1
-18
@@ -17,7 +17,7 @@ use crate::bytes::Vtable;
|
||||
#[allow(unused)]
|
||||
use crate::loom::sync::atomic::AtomicMut;
|
||||
use crate::loom::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
|
||||
use crate::{Buf, BufMut, Bytes};
|
||||
use crate::{offset_from, Buf, BufMut, Bytes};
|
||||
|
||||
/// A unique reference to a contiguous slice of memory.
|
||||
///
|
||||
@@ -1683,23 +1683,6 @@ fn invalid_ptr<T>(addr: usize) -> *mut T {
|
||||
ptr.cast::<T>()
|
||||
}
|
||||
|
||||
/// 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: *mut u8, original: *mut u8) -> usize {
|
||||
debug_assert!(dst >= original);
|
||||
|
||||
dst as usize - original as usize
|
||||
}
|
||||
|
||||
unsafe fn rebuild_vec(ptr: *mut u8, mut len: usize, mut cap: usize, off: usize) -> Vec<u8> {
|
||||
let ptr = ptr.sub(off);
|
||||
len += off;
|
||||
|
||||
Reference in New Issue
Block a user