| 1 |
#[allow( |
| 2 |
deprecated, |
| 3 |
private_bounds, |
| 4 |
non_local_definitions, |
| 5 |
non_camel_case_types, |
| 6 |
non_upper_case_globals, |
| 7 |
non_snake_case, |
| 8 |
non_ascii_idents, |
| 9 |
clippy::missing_inline_in_public_items, |
| 10 |
)] |
| 11 |
#[deny(ambiguous_associated_items)] |
| 12 |
#[automatically_derived] |
| 13 |
const _: () = { |
| 14 |
unsafe impl<T, U> ::zerocopy::KnownLayout for Foo<T, U> |
| 15 |
where |
| 16 |
U: ::zerocopy::KnownLayout, |
| 17 |
{ |
| 18 |
fn only_derive_is_allowed_to_implement_this_trait() {} |
| 19 |
type PointerMetadata = <U as ::zerocopy::KnownLayout>::PointerMetadata; |
| 20 |
type MaybeUninit = __ZerocopyKnownLayoutMaybeUninit<T, U>; |
| 21 |
const LAYOUT: ::zerocopy::DstLayout = ::zerocopy::DstLayout::for_repr_c_struct( |
| 22 |
::zerocopy::util::macro_util::core_reexport::num::NonZeroUsize::new( |
| 23 |
2u32 as usize, |
| 24 |
), |
| 25 |
::zerocopy::util::macro_util::core_reexport::option::Option::None, |
| 26 |
&[ |
| 27 |
::zerocopy::DstLayout::for_type::<T>(), |
| 28 |
<U as ::zerocopy::KnownLayout>::LAYOUT, |
| 29 |
], |
| 30 |
); |
| 31 |
#[inline(always)] |
| 32 |
fn raw_from_ptr_len( |
| 33 |
bytes: ::zerocopy::util::macro_util::core_reexport::ptr::NonNull<u8>, |
| 34 |
meta: <Self as ::zerocopy::KnownLayout>::PointerMetadata, |
| 35 |
) -> ::zerocopy::util::macro_util::core_reexport::ptr::NonNull<Self> { |
| 36 |
let trailing = <U as ::zerocopy::KnownLayout>::raw_from_ptr_len(bytes, meta); |
| 37 |
let slf = trailing.as_ptr() as *mut Self; |
| 38 |
unsafe { |
| 39 |
::zerocopy::util::macro_util::core_reexport::ptr::NonNull::new_unchecked( |
| 40 |
slf, |
| 41 |
) |
| 42 |
} |
| 43 |
} |
| 44 |
#[inline(always)] |
| 45 |
fn pointer_to_metadata( |
| 46 |
ptr: *mut Self, |
| 47 |
) -> <Self as ::zerocopy::KnownLayout>::PointerMetadata { |
| 48 |
<U>::pointer_to_metadata(ptr as *mut _) |
| 49 |
} |
| 50 |
} |
| 51 |
struct __Zerocopy_Field_0; |
| 52 |
struct __Zerocopy_Field_1; |
| 53 |
unsafe impl<T, U> ::zerocopy::util::macro_util::Field<__Zerocopy_Field_0> |
| 54 |
for Foo<T, U> { |
| 55 |
type Type = T; |
| 56 |
} |
| 57 |
unsafe impl<T, U> ::zerocopy::util::macro_util::Field<__Zerocopy_Field_1> |
| 58 |
for Foo<T, U> { |
| 59 |
type Type = U; |
| 60 |
} |
| 61 |
#[repr(C)] |
| 62 |
#[repr(align(2))] |
| 63 |
#[doc(hidden)] |
| 64 |
struct __ZerocopyKnownLayoutMaybeUninit<T, U>( |
| 65 |
::zerocopy::util::macro_util::core_reexport::mem::MaybeUninit< |
| 66 |
<Foo<T, U> as ::zerocopy::util::macro_util::Field<__Zerocopy_Field_0>>::Type, |
| 67 |
>, |
| 68 |
::zerocopy::util::macro_util::core_reexport::mem::ManuallyDrop< |
| 69 |
<<Foo< |
| 70 |
T, |
| 71 |
U, |
| 72 |
> as ::zerocopy::util::macro_util::Field< |
| 73 |
__Zerocopy_Field_1, |
| 74 |
>>::Type as ::zerocopy::KnownLayout>::MaybeUninit, |
| 75 |
>, |
| 76 |
) |
| 77 |
where |
| 78 |
<Foo< |
| 79 |
T, |
| 80 |
U, |
| 81 |
> as ::zerocopy::util::macro_util::Field< |
| 82 |
__Zerocopy_Field_1, |
| 83 |
>>::Type: ::zerocopy::KnownLayout; |
| 84 |
unsafe impl<T, U> ::zerocopy::KnownLayout for __ZerocopyKnownLayoutMaybeUninit<T, U> |
| 85 |
where |
| 86 |
<Foo< |
| 87 |
T, |
| 88 |
U, |
| 89 |
> as ::zerocopy::util::macro_util::Field< |
| 90 |
__Zerocopy_Field_1, |
| 91 |
>>::Type: ::zerocopy::KnownLayout, |
| 92 |
{ |
| 93 |
fn only_derive_is_allowed_to_implement_this_trait() {} |
| 94 |
type PointerMetadata = <Foo<T, U> as ::zerocopy::KnownLayout>::PointerMetadata; |
| 95 |
type MaybeUninit = Self; |
| 96 |
const LAYOUT: ::zerocopy::DstLayout = <Foo< |
| 97 |
T, |
| 98 |
U, |
| 99 |
> as ::zerocopy::KnownLayout>::LAYOUT; |
| 100 |
#[inline(always)] |
| 101 |
fn raw_from_ptr_len( |
| 102 |
bytes: ::zerocopy::util::macro_util::core_reexport::ptr::NonNull<u8>, |
| 103 |
meta: <Self as ::zerocopy::KnownLayout>::PointerMetadata, |
| 104 |
) -> ::zerocopy::util::macro_util::core_reexport::ptr::NonNull<Self> { |
| 105 |
let trailing = <<<Foo< |
| 106 |
T, |
| 107 |
U, |
| 108 |
> as ::zerocopy::util::macro_util::Field< |
| 109 |
__Zerocopy_Field_1, |
| 110 |
>>::Type as ::zerocopy::KnownLayout>::MaybeUninit as ::zerocopy::KnownLayout>::raw_from_ptr_len( |
| 111 |
bytes, |
| 112 |
meta, |
| 113 |
); |
| 114 |
let slf = trailing.as_ptr() as *mut Self; |
| 115 |
unsafe { |
| 116 |
::zerocopy::util::macro_util::core_reexport::ptr::NonNull::new_unchecked( |
| 117 |
slf, |
| 118 |
) |
| 119 |
} |
| 120 |
} |
| 121 |
#[inline(always)] |
| 122 |
fn pointer_to_metadata( |
| 123 |
ptr: *mut Self, |
| 124 |
) -> <Self as ::zerocopy::KnownLayout>::PointerMetadata { |
| 125 |
<<<Foo< |
| 126 |
T, |
| 127 |
U, |
| 128 |
> as ::zerocopy::util::macro_util::Field< |
| 129 |
__Zerocopy_Field_1, |
| 130 |
>>::Type as ::zerocopy::KnownLayout>::MaybeUninit>::pointer_to_metadata( |
| 131 |
ptr as *mut _, |
| 132 |
) |
| 133 |
} |
| 134 |
} |
| 135 |
}; |