File tree 1 file changed +1
-22
lines changed
1 file changed +1
-22
lines changed Original file line number Diff line number Diff line change @@ -5,31 +5,10 @@ use crate::bindings::*;
5
5
6
6
use std:: ffi:: { c_void, CStr } ;
7
7
use std:: marker:: PhantomData ;
8
+ use std:: mem:: offset_of;
8
9
use std:: ptr:: NonNull ;
9
10
use std:: str;
10
11
11
- // from https://internals.rust-lang.org/t/discussion-on-offset-of/7440/2
12
- macro_rules! offset_of {
13
- ( $Struct: path, $field: ident) => { {
14
- // Using a separate function to minimize unhygienic hazards
15
- // (e.g. unsafety of #[repr(packed)] field borrows).
16
- // Uncomment `const` when `const fn`s can juggle pointers.
17
-
18
- // const
19
- fn offset( ) -> usize {
20
- let u = std:: mem:: MaybeUninit :: <$Struct>:: uninit( ) ;
21
- // Use pattern-matching to avoid accidentally going through Deref.
22
- let & $Struct { $field: ref f, .. } = unsafe { & * u. as_ptr( ) } ;
23
- let o =
24
- ( f as * const _ as usize ) . wrapping_sub( & u as * const _ as usize ) ;
25
- // Triple check that we are within `u` still.
26
- assert!( ( 0 ..=std:: mem:: size_of_val( & u) ) . contains( & o) ) ;
27
- o
28
- }
29
- offset( )
30
- } } ;
31
- }
32
-
33
12
pub struct ExecListIter < ' a , T > {
34
13
n : & ' a exec_node ,
35
14
offset : usize ,
You can’t perform that action at this time.
0 commit comments