1- use core:: iter:: FromIterator ;
21use core:: mem:: { self , ManuallyDrop } ;
32use core:: ops:: { Deref , RangeBounds } ;
43use core:: ptr:: NonNull ;
5- use core:: { cmp, fmt, hash, ptr, slice, usize } ;
4+ use core:: { cmp, fmt, hash, ptr, slice} ;
65
76use alloc:: {
87 alloc:: { dealloc, Layout } ,
@@ -16,7 +15,7 @@ use crate::buf::IntoIter;
1615#[ allow( unused) ]
1716use crate :: loom:: sync:: atomic:: AtomicMut ;
1817use crate :: loom:: sync:: atomic:: { AtomicPtr , AtomicUsize , Ordering } ;
19- use crate :: { offset_from , Buf , BytesMut } ;
18+ use crate :: { Buf , BytesMut } ;
2019
2120/// A cheaply cloneable and sliceable chunk of contiguous memory.
2221///
@@ -1235,7 +1234,7 @@ unsafe fn promotable_to_vec(
12351234
12361235 let buf = f ( shared) ;
12371236
1238- let cap = offset_from ( ptr , buf) + len;
1237+ let cap = ptr . offset_from ( buf) as usize + len;
12391238
12401239 // Copy back buffer
12411240 ptr:: copy ( ptr, buf, len) ;
@@ -1263,7 +1262,7 @@ unsafe fn promotable_to_mut(
12631262 debug_assert_eq ! ( kind, KIND_VEC ) ;
12641263
12651264 let buf = f ( shared) ;
1266- let off = offset_from ( ptr , buf) ;
1265+ let off = ptr . offset_from ( buf) as usize ;
12671266 let cap = off + len;
12681267 let v = Vec :: from_raw_parts ( buf, cap, cap) ;
12691268
@@ -1348,7 +1347,7 @@ unsafe fn promotable_is_unique(data: &AtomicPtr<()>) -> bool {
13481347}
13491348
13501349unsafe fn free_boxed_slice ( buf : * mut u8 , offset : * const u8 , len : usize ) {
1351- let cap = offset_from ( offset , buf) + len;
1350+ let cap = offset . offset_from ( buf) as usize + len;
13521351 dealloc ( buf, Layout :: from_size_align ( cap, 1 ) . unwrap ( ) )
13531352}
13541353
@@ -1444,7 +1443,7 @@ unsafe fn shared_to_mut_impl(shared: *mut Shared, ptr: *const u8, len: usize) ->
14441443 let cap = shared. cap ;
14451444
14461445 // Rebuild Vec
1447- let off = offset_from ( ptr , buf) ;
1446+ let off = ptr . offset_from ( buf) as usize ;
14481447 let v = Vec :: from_raw_parts ( buf, len + off, cap) ;
14491448
14501449 let mut b = BytesMut :: from_vec ( v) ;
@@ -1510,7 +1509,7 @@ unsafe fn shallow_clone_vec(
15101509 // vector.
15111510 let shared = Box :: new ( Shared {
15121511 buf,
1513- cap : offset_from ( offset , buf) + len,
1512+ cap : offset . offset_from ( buf) as usize + len,
15141513 // Initialize refcount to 2. One for this reference, and one
15151514 // for the new clone that will be returned from
15161515 // `shallow_clone`.
0 commit comments