/rust/registry/src/index.crates.io-1949cf8c6b5b557f/bytemuck-1.24.0/src/lib.rs
Line | Count | Source |
1 | | #![no_std] |
2 | | #![warn(missing_docs)] |
3 | | #![allow(unused_mut)] |
4 | | #![allow(clippy::match_like_matches_macro)] |
5 | | #![allow(clippy::uninlined_format_args)] |
6 | | #![allow(clippy::result_unit_err)] |
7 | | #![allow(clippy::type_complexity)] |
8 | | #![allow(clippy::manual_is_multiple_of)] |
9 | | #![cfg_attr(feature = "nightly_docs", feature(doc_cfg))] |
10 | | #![cfg_attr(feature = "nightly_portable_simd", feature(portable_simd))] |
11 | | #![cfg_attr(feature = "nightly_float", feature(f16, f128))] |
12 | | |
13 | | //! This crate gives small utilities for casting between plain data types. |
14 | | //! |
15 | | //! ## Basics |
16 | | //! |
17 | | //! Data comes in five basic forms in Rust, so we have five basic casting |
18 | | //! functions: |
19 | | //! |
20 | | //! * `T` uses [`cast`] |
21 | | //! * `&T` uses [`cast_ref`] |
22 | | //! * `&mut T` uses [`cast_mut`] |
23 | | //! * `&[T]` uses [`cast_slice`] |
24 | | //! * `&mut [T]` uses [`cast_slice_mut`] |
25 | | //! |
26 | | //! Depending on the function, the [`NoUninit`] and/or [`AnyBitPattern`] traits |
27 | | //! are used to maintain memory safety. |
28 | | //! |
29 | | //! **Historical Note:** When the crate first started the [`Pod`] trait was used |
30 | | //! instead, and so you may hear people refer to that, but it has the strongest |
31 | | //! requirements and people eventually wanted the more fine-grained system, so |
32 | | //! here we are. All types that impl `Pod` have a blanket impl to also support |
33 | | //! `NoUninit` and `AnyBitPattern`. The traits unfortunately do not have a |
34 | | //! perfectly clean hierarchy for semver reasons. |
35 | | //! |
36 | | //! ## Failures |
37 | | //! |
38 | | //! Some casts will never fail, and other casts might fail. |
39 | | //! |
40 | | //! * `cast::<u32, f32>` always works (and [`f32::from_bits`]). |
41 | | //! * `cast_ref::<[u8; 4], u32>` might fail if the specific array reference |
42 | | //! given at runtime doesn't have alignment 4. |
43 | | //! |
44 | | //! In addition to the "normal" forms of each function, which will panic on |
45 | | //! invalid input, there's also `try_` versions which will return a `Result`. |
46 | | //! |
47 | | //! If you would like to statically ensure that a cast will work at runtime you |
48 | | //! can use the `must_cast` crate feature and the `must_` casting functions. A |
49 | | //! "must cast" that can't be statically known to be valid will cause a |
50 | | //! compilation error (and sometimes a very hard to read compilation error). |
51 | | //! |
52 | | //! ## Using Your Own Types |
53 | | //! |
54 | | //! All the functions listed above are guarded by the [`Pod`] trait, which is a |
55 | | //! sub-trait of the [`Zeroable`] trait. |
56 | | //! |
57 | | //! If you enable the crate's `derive` feature then these traits can be derived |
58 | | //! on your own types. The derive macros will perform the necessary checks on |
59 | | //! your type declaration, and trigger an error if your type does not qualify. |
60 | | //! |
61 | | //! The derive macros might not cover all edge cases, and sometimes they will |
62 | | //! error when actually everything is fine. As a last resort you can impl these |
63 | | //! traits manually. However, these traits are `unsafe`, and you should |
64 | | //! carefully read the requirements before using a manual implementation. |
65 | | //! |
66 | | //! ## Cargo Features |
67 | | //! |
68 | | //! The crate supports Rust 1.34 when no features are enabled, and so there's |
69 | | //! cargo features for thing that you might consider "obvious". |
70 | | //! |
71 | | //! The cargo features **do not** promise any particular MSRV, and they may |
72 | | //! increase their MSRV in new versions. |
73 | | //! |
74 | | //! * `derive`: Provide derive macros for the various traits. |
75 | | //! * `extern_crate_alloc`: Provide utilities for `alloc` related types such as |
76 | | //! Box and Vec. |
77 | | //! * `zeroable_maybe_uninit` and `zeroable_atomics`: Provide more [`Zeroable`] |
78 | | //! impls. |
79 | | //! * `pod_saturating`: Provide more [`Pod`] and [`Zeroable`] impls. |
80 | | //! * `wasm_simd` and `aarch64_simd`: Support more SIMD types. |
81 | | //! * `min_const_generics`: Provides appropriate impls for arrays of all lengths |
82 | | //! instead of just for a select list of array lengths. |
83 | | //! * `must_cast`: Provides the `must_` functions, which will compile error if |
84 | | //! the requested cast can't be statically verified. |
85 | | //! * `const_zeroed`: Provides a const version of the `zeroed` function. |
86 | | //! |
87 | | //! ## Related Crates |
88 | | //! |
89 | | //! - [`pack1`](https://docs.rs/pack1), which contains `bytemuck`-compatible |
90 | | //! packed little-endian, big-endian and native-endian integer and floating |
91 | | //! point number types. |
92 | | |
93 | | #[cfg(all(target_arch = "aarch64", feature = "aarch64_simd"))] |
94 | | use core::arch::aarch64; |
95 | | #[cfg(all(target_arch = "wasm32", feature = "wasm_simd"))] |
96 | | use core::arch::wasm32; |
97 | | #[cfg(target_arch = "x86")] |
98 | | use core::arch::x86; |
99 | | #[cfg(target_arch = "x86_64")] |
100 | | use core::arch::x86_64; |
101 | | // |
102 | | use core::{ |
103 | | marker::*, |
104 | | mem::{align_of, size_of}, |
105 | | num::*, |
106 | | ptr::*, |
107 | | }; |
108 | | |
109 | | // Used from macros to ensure we aren't using some locally defined name and |
110 | | // actually are referencing libcore. This also would allow pre-2018 edition |
111 | | // crates to use our macros, but I'm not sure how important that is. |
112 | | #[doc(hidden)] |
113 | | pub use ::core as __core; |
114 | | |
115 | | #[cfg(not(feature = "min_const_generics"))] |
116 | | macro_rules! impl_unsafe_marker_for_array { |
117 | | ( $marker:ident , $( $n:expr ),* ) => { |
118 | | $(unsafe impl<T> $marker for [T; $n] where T: $marker {})* |
119 | | } |
120 | | } |
121 | | |
122 | | /// A macro to transmute between two types without requiring knowing size |
123 | | /// statically. |
124 | | macro_rules! transmute { |
125 | | ($val:expr) => { |
126 | | ::core::mem::transmute_copy(&::core::mem::ManuallyDrop::new($val)) |
127 | | }; |
128 | | // This arm is for use in const contexts, where the borrow required to use |
129 | | // transmute_copy poses an issue since the compiler hedges that the type |
130 | | // being borrowed could have interior mutability. |
131 | | ($srcty:ty; $dstty:ty; $val:expr) => {{ |
132 | | #[repr(C)] |
133 | | union Transmute<A, B> { |
134 | | src: ::core::mem::ManuallyDrop<A>, |
135 | | dst: ::core::mem::ManuallyDrop<B>, |
136 | | } |
137 | | ::core::mem::ManuallyDrop::into_inner( |
138 | | Transmute::<$srcty, $dstty> { src: ::core::mem::ManuallyDrop::new($val) } |
139 | | .dst, |
140 | | ) |
141 | | }}; |
142 | | } |
143 | | |
144 | | /// A macro to implement marker traits for various simd types. |
145 | | /// #[allow(unused)] because the impls are only compiled on relevant platforms |
146 | | /// with relevant cargo features enabled. |
147 | | #[allow(unused)] |
148 | | macro_rules! impl_unsafe_marker_for_simd { |
149 | | ($(#[cfg($cfg_predicate:meta)])? unsafe impl $trait:ident for $platform:ident :: {}) => {}; |
150 | | ($(#[cfg($cfg_predicate:meta)])? unsafe impl $trait:ident for $platform:ident :: { $first_type:ident $(, $types:ident)* $(,)? }) => { |
151 | | $( #[cfg($cfg_predicate)] )? |
152 | | $( #[cfg_attr(feature = "nightly_docs", doc(cfg($cfg_predicate)))] )? |
153 | | unsafe impl $trait for $platform::$first_type {} |
154 | | $( #[cfg($cfg_predicate)] )? // To prevent recursion errors if nothing is going to be expanded anyway. |
155 | | impl_unsafe_marker_for_simd!($( #[cfg($cfg_predicate)] )? unsafe impl $trait for $platform::{ $( $types ),* }); |
156 | | }; |
157 | | } |
158 | | |
159 | | /// A macro for conditionally const-ifying a function. |
160 | | /// #[allow(unused)] because currently it is only used with the `must_cast` feature. |
161 | | #[allow(unused)] |
162 | | macro_rules! maybe_const_fn { |
163 | | ( |
164 | | #[cfg($cfg_predicate:meta)] |
165 | | $(#[$attr:meta])* |
166 | | $vis:vis $(unsafe $($unsafe:lifetime)?)? fn $name:ident $($rest:tt)* |
167 | | ) => { |
168 | | #[cfg($cfg_predicate)] |
169 | | $(#[$attr])* |
170 | | $vis const $(unsafe $($unsafe)?)? fn $name $($rest)* |
171 | | |
172 | | #[cfg(not($cfg_predicate))] |
173 | | $(#[$attr])* |
174 | | $vis $(unsafe $($unsafe)?)? fn $name $($rest)* |
175 | | }; |
176 | | } |
177 | | |
178 | | #[cfg(feature = "extern_crate_std")] |
179 | | extern crate std; |
180 | | |
181 | | #[cfg(feature = "extern_crate_alloc")] |
182 | | extern crate alloc; |
183 | | #[cfg(feature = "extern_crate_alloc")] |
184 | | #[cfg_attr(feature = "nightly_docs", doc(cfg(feature = "extern_crate_alloc")))] |
185 | | pub mod allocation; |
186 | | #[cfg(feature = "extern_crate_alloc")] |
187 | | pub use allocation::*; |
188 | | |
189 | | mod anybitpattern; |
190 | | pub use anybitpattern::*; |
191 | | |
192 | | pub mod checked; |
193 | | pub use checked::CheckedBitPattern; |
194 | | |
195 | | mod internal; |
196 | | |
197 | | mod zeroable; |
198 | | pub use zeroable::*; |
199 | | mod zeroable_in_option; |
200 | | pub use zeroable_in_option::*; |
201 | | |
202 | | mod pod; |
203 | | pub use pod::*; |
204 | | mod pod_in_option; |
205 | | pub use pod_in_option::*; |
206 | | |
207 | | #[cfg(feature = "must_cast")] |
208 | | mod must; |
209 | | #[cfg(feature = "must_cast")] |
210 | | #[cfg_attr(feature = "nightly_docs", doc(cfg(feature = "must_cast")))] |
211 | | pub use must::*; |
212 | | |
213 | | mod no_uninit; |
214 | | pub use no_uninit::*; |
215 | | |
216 | | mod contiguous; |
217 | | pub use contiguous::*; |
218 | | |
219 | | mod offset_of; |
220 | | // ^ no import, the module only has a macro_rules, which are cursed and don't |
221 | | // follow normal import/export rules. |
222 | | |
223 | | mod transparent; |
224 | | pub use transparent::*; |
225 | | |
226 | | // This module is just an implementation detail for the derive macros. It needs |
227 | | // to be public to be usable from the macros, but it shouldn't be considered |
228 | | // part of bytemuck's public API. |
229 | | #[cfg(feature = "derive")] |
230 | | #[doc(hidden)] |
231 | | pub mod derive; |
232 | | |
233 | | #[cfg(feature = "derive")] |
234 | | #[cfg_attr(feature = "nightly_docs", doc(cfg(feature = "derive")))] |
235 | | pub use bytemuck_derive::{ |
236 | | AnyBitPattern, ByteEq, ByteHash, CheckedBitPattern, Contiguous, NoUninit, |
237 | | Pod, TransparentWrapper, Zeroable, |
238 | | }; |
239 | | |
240 | | /// The things that can go wrong when casting between [`Pod`] data forms. |
241 | | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
242 | | pub enum PodCastError { |
243 | | /// You tried to cast a reference into a reference to a type with a higher |
244 | | /// alignment requirement but the input reference wasn't aligned. |
245 | | TargetAlignmentGreaterAndInputNotAligned, |
246 | | /// If the element size of a slice changes, then the output slice changes |
247 | | /// length accordingly. If the output slice wouldn't be a whole number of |
248 | | /// elements, then the conversion fails. |
249 | | OutputSliceWouldHaveSlop, |
250 | | /// When casting an individual `T`, `&T`, or `&mut T` value the |
251 | | /// source size and destination size must be an exact match. |
252 | | SizeMismatch, |
253 | | /// For this type of cast the alignments must be exactly the same and they |
254 | | /// were not so now you're sad. |
255 | | /// |
256 | | /// This error is generated **only** by operations that cast allocated types |
257 | | /// (such as `Box` and `Vec`), because in that case the alignment must stay |
258 | | /// exact. |
259 | | AlignmentMismatch, |
260 | | } |
261 | | #[cfg(not(target_arch = "spirv"))] |
262 | | impl core::fmt::Display for PodCastError { |
263 | 0 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
264 | 0 | write!(f, "{:?}", self) |
265 | 0 | } |
266 | | } |
267 | | #[cfg(feature = "extern_crate_std")] |
268 | | #[cfg_attr(feature = "nightly_docs", doc(cfg(feature = "extern_crate_std")))] |
269 | | impl std::error::Error for PodCastError {} |
270 | | |
271 | | // Rust 1.81+ |
272 | | #[cfg(all(feature = "impl_core_error", not(feature = "extern_crate_std")))] |
273 | | impl core::error::Error for PodCastError {} |
274 | | |
275 | | /// Re-interprets `&T` as `&[u8]`. |
276 | | /// |
277 | | /// Any ZST becomes an empty slice, and in that case the pointer value of that |
278 | | /// empty slice might not match the pointer value of the input reference. |
279 | | #[inline] |
280 | 0 | pub fn bytes_of<T: NoUninit>(t: &T) -> &[u8] { |
281 | 0 | unsafe { internal::bytes_of(t) } |
282 | 0 | } |
283 | | |
284 | | /// Re-interprets `&mut T` as `&mut [u8]`. |
285 | | /// |
286 | | /// Any ZST becomes an empty slice, and in that case the pointer value of that |
287 | | /// empty slice might not match the pointer value of the input reference. |
288 | | #[inline] |
289 | 0 | pub fn bytes_of_mut<T: NoUninit + AnyBitPattern>(t: &mut T) -> &mut [u8] { |
290 | 0 | unsafe { internal::bytes_of_mut(t) } |
291 | 0 | } |
292 | | |
293 | | /// Re-interprets `&[u8]` as `&T`. |
294 | | /// |
295 | | /// ## Panics |
296 | | /// |
297 | | /// This is like [`try_from_bytes`] but will panic on error. |
298 | | #[inline] |
299 | | #[cfg_attr(feature = "track_caller", track_caller)] |
300 | 0 | pub fn from_bytes<T: AnyBitPattern>(s: &[u8]) -> &T { |
301 | 0 | unsafe { internal::from_bytes(s) } |
302 | 0 | } |
303 | | |
304 | | /// Re-interprets `&mut [u8]` as `&mut T`. |
305 | | /// |
306 | | /// ## Panics |
307 | | /// |
308 | | /// This is like [`try_from_bytes_mut`] but will panic on error. |
309 | | #[inline] |
310 | | #[cfg_attr(feature = "track_caller", track_caller)] |
311 | 0 | pub fn from_bytes_mut<T: NoUninit + AnyBitPattern>(s: &mut [u8]) -> &mut T { |
312 | 0 | unsafe { internal::from_bytes_mut(s) } |
313 | 0 | } |
314 | | |
315 | | /// Reads from the bytes as if they were a `T`. |
316 | | /// |
317 | | /// Unlike [`from_bytes`], the slice doesn't need to respect alignment of `T`, |
318 | | /// only sizes must match. |
319 | | /// |
320 | | /// ## Failure |
321 | | /// * If the `bytes` length is not equal to `size_of::<T>()`. |
322 | | #[inline] |
323 | 0 | pub fn try_pod_read_unaligned<T: AnyBitPattern>( |
324 | 0 | bytes: &[u8], |
325 | 0 | ) -> Result<T, PodCastError> { |
326 | 0 | unsafe { internal::try_pod_read_unaligned(bytes) } |
327 | 0 | } |
328 | | |
329 | | /// Reads the slice into a `T` value. |
330 | | /// |
331 | | /// Unlike [`from_bytes`], the slice doesn't need to respect alignment of `T`, |
332 | | /// only sizes must match. |
333 | | /// |
334 | | /// ## Panics |
335 | | /// * This is like `try_pod_read_unaligned` but will panic on failure. |
336 | | #[inline] |
337 | | #[cfg_attr(feature = "track_caller", track_caller)] |
338 | 0 | pub fn pod_read_unaligned<T: AnyBitPattern>(bytes: &[u8]) -> T { |
339 | 0 | unsafe { internal::pod_read_unaligned(bytes) } |
340 | 0 | } |
341 | | |
342 | | /// Re-interprets `&[u8]` as `&T`. |
343 | | /// |
344 | | /// ## Failure |
345 | | /// |
346 | | /// * If the slice isn't aligned for the new type |
347 | | /// * If the slice's length isn’t exactly the size of the new type |
348 | | #[inline] |
349 | 0 | pub fn try_from_bytes<T: AnyBitPattern>(s: &[u8]) -> Result<&T, PodCastError> { |
350 | 0 | unsafe { internal::try_from_bytes(s) } |
351 | 0 | } |
352 | | |
353 | | /// Re-interprets `&mut [u8]` as `&mut T`. |
354 | | /// |
355 | | /// ## Failure |
356 | | /// |
357 | | /// * If the slice isn't aligned for the new type |
358 | | /// * If the slice's length isn’t exactly the size of the new type |
359 | | #[inline] |
360 | 0 | pub fn try_from_bytes_mut<T: NoUninit + AnyBitPattern>( |
361 | 0 | s: &mut [u8], |
362 | 0 | ) -> Result<&mut T, PodCastError> { |
363 | 0 | unsafe { internal::try_from_bytes_mut(s) } |
364 | 0 | } |
365 | | |
366 | | /// Cast `A` into `B` |
367 | | /// |
368 | | /// ## Panics |
369 | | /// |
370 | | /// * This is like [`try_cast`], but will panic on a size mismatch. |
371 | | #[inline] |
372 | | #[cfg_attr(feature = "track_caller", track_caller)] |
373 | 0 | pub fn cast<A: NoUninit, B: AnyBitPattern>(a: A) -> B { |
374 | 0 | unsafe { internal::cast(a) } |
375 | 0 | } |
376 | | |
377 | | /// Cast `&mut A` into `&mut B`. |
378 | | /// |
379 | | /// ## Panics |
380 | | /// |
381 | | /// This is [`try_cast_mut`] but will panic on error. |
382 | | #[inline] |
383 | | #[cfg_attr(feature = "track_caller", track_caller)] |
384 | 0 | pub fn cast_mut<A: NoUninit + AnyBitPattern, B: NoUninit + AnyBitPattern>( |
385 | 0 | a: &mut A, |
386 | 0 | ) -> &mut B { |
387 | 0 | unsafe { internal::cast_mut(a) } |
388 | 0 | } |
389 | | |
390 | | /// Cast `&A` into `&B`. |
391 | | /// |
392 | | /// ## Panics |
393 | | /// |
394 | | /// This is [`try_cast_ref`] but will panic on error. |
395 | | #[inline] |
396 | | #[cfg_attr(feature = "track_caller", track_caller)] |
397 | 0 | pub fn cast_ref<A: NoUninit, B: AnyBitPattern>(a: &A) -> &B { |
398 | 0 | unsafe { internal::cast_ref(a) } |
399 | 0 | } |
400 | | |
401 | | /// Cast `&[A]` into `&[B]`. |
402 | | /// |
403 | | /// ## Panics |
404 | | /// |
405 | | /// This is [`try_cast_slice`] but will panic on error. |
406 | | #[inline] |
407 | | #[cfg_attr(feature = "track_caller", track_caller)] |
408 | 7.08G | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { |
409 | 7.08G | unsafe { internal::cast_slice(a) } |
410 | 7.08G | } bytemuck::cast_slice::<u8, i8> Line | Count | Source | 408 | 526k | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 526k | unsafe { internal::cast_slice(a) } | 410 | 526k | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, font_types::raw::BigEndian<font_types::offset::Nullable<font_types::offset::Offset16>>> bytemuck::cast_slice::<u8, font_types::raw::BigEndian<font_types::offset::Nullable<font_types::offset::Offset32>>> Line | Count | Source | 408 | 38.8M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 38.8M | unsafe { internal::cast_slice(a) } | 410 | 38.8M | } |
bytemuck::cast_slice::<u8, font_types::raw::BigEndian<font_types::tag::Tag>> Line | Count | Source | 408 | 49.0k | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 49.0k | unsafe { internal::cast_slice(a) } | 410 | 49.0k | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, font_types::raw::BigEndian<font_types::fixed::Fixed>> bytemuck::cast_slice::<u8, font_types::raw::BigEndian<font_types::fixed::F2Dot14>> Line | Count | Source | 408 | 2.06M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 2.06M | unsafe { internal::cast_slice(a) } | 410 | 2.06M | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, font_types::raw::BigEndian<font_types::offset::Offset16>> Unexecuted instantiation: bytemuck::cast_slice::<u8, font_types::raw::BigEndian<font_types::offset::Offset24>> bytemuck::cast_slice::<u8, font_types::raw::BigEndian<font_types::offset::Offset32>> Line | Count | Source | 408 | 239k | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 239k | unsafe { internal::cast_slice(a) } | 410 | 239k | } |
bytemuck::cast_slice::<u8, font_types::raw::BigEndian<font_types::uint24::Uint24>> Line | Count | Source | 408 | 62.5k | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 62.5k | unsafe { internal::cast_slice(a) } | 410 | 62.5k | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, font_types::raw::BigEndian<font_types::name_id::NameId>> Unexecuted instantiation: bytemuck::cast_slice::<u8, font_types::raw::BigEndian<font_types::glyph_id::GlyphId16>> Unexecuted instantiation: bytemuck::cast_slice::<u8, font_types::raw::BigEndian<read_fonts::tables::cpal::PaletteType>> bytemuck::cast_slice::<u8, font_types::raw::BigEndian<i32>> Line | Count | Source | 408 | 2.11k | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 2.11k | unsafe { internal::cast_slice(a) } | 410 | 2.11k | } |
bytemuck::cast_slice::<u8, font_types::raw::BigEndian<u32>> Line | Count | Source | 408 | 6.90M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 6.90M | unsafe { internal::cast_slice(a) } | 410 | 6.90M | } |
bytemuck::cast_slice::<u8, font_types::raw::BigEndian<i16>> Line | Count | Source | 408 | 2.48G | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 2.48G | unsafe { internal::cast_slice(a) } | 410 | 2.48G | } |
bytemuck::cast_slice::<u8, font_types::raw::BigEndian<u16>> Line | Count | Source | 408 | 3.67G | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 3.67G | unsafe { internal::cast_slice(a) } | 410 | 3.67G | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::aat::LookupSingle<u32>> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::aat::LookupSingle<u16>> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::aat::LookupSegment2<u32>> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::aat::LookupSegment2<u16>> bytemuck::cast_slice::<u8, read_fonts::TableRecord> Line | Count | Source | 408 | 81.0M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 81.0M | unsafe { internal::cast_slice(a) } | 410 | 81.0M | } |
bytemuck::cast_slice::<u8, read_fonts::tables::postscript::CharsetRange1> Line | Count | Source | 408 | 14.3k | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 14.3k | unsafe { internal::cast_slice(a) } | 410 | 14.3k | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::postscript::CharsetRange2> bytemuck::cast_slice::<u8, read_fonts::tables::postscript::FdSelectRange3> Line | Count | Source | 408 | 4.54M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 4.54M | unsafe { internal::cast_slice(a) } | 410 | 4.54M | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::postscript::FdSelectRange4> bytemuck::cast_slice::<u8, read_fonts::tables::variations::RegionAxisCoordinates> Line | Count | Source | 408 | 5.03M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 5.03M | unsafe { internal::cast_slice(a) } | 410 | 5.03M | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::aat::LookupSegment4> bytemuck::cast_slice::<u8, read_fonts::tables::ift::DesignSpaceSegment> Line | Count | Source | 408 | 49.0k | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 49.0k | unsafe { internal::cast_slice(a) } | 410 | 49.0k | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::svg::SVGDocumentRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::ankr::AnchorPoint> bytemuck::cast_slice::<u8, read_fonts::tables::avar::AxisValueMap> Line | Count | Source | 408 | 348k | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 348k | unsafe { internal::cast_slice(a) } | 410 | 348k | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::base::BaseScriptRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::base::FeatMinMaxRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::base::BaseLangSysRecord> bytemuck::cast_slice::<u8, read_fonts::tables::cmap::UvsMapping> Line | Count | Source | 408 | 9.69M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 9.69M | unsafe { internal::cast_slice(a) } | 410 | 9.69M | } |
bytemuck::cast_slice::<u8, read_fonts::tables::cmap::UnicodeRange> Line | Count | Source | 408 | 15.3M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 15.3M | unsafe { internal::cast_slice(a) } | 410 | 15.3M | } |
bytemuck::cast_slice::<u8, read_fonts::tables::cmap::EncodingRecord> Line | Count | Source | 408 | 1.64M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 1.64M | unsafe { internal::cast_slice(a) } | 410 | 1.64M | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::cmap::ConstantMapGroup> bytemuck::cast_slice::<u8, read_fonts::tables::cmap::VariationSelector> Line | Count | Source | 408 | 93.4M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 93.4M | unsafe { internal::cast_slice(a) } | 410 | 93.4M | } |
bytemuck::cast_slice::<u8, read_fonts::tables::cmap::SequentialMapGroup> Line | Count | Source | 408 | 112M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 112M | unsafe { internal::cast_slice(a) } | 410 | 112M | } |
bytemuck::cast_slice::<u8, read_fonts::tables::colr::VarColorStop> Line | Count | Source | 408 | 615k | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 615k | unsafe { internal::cast_slice(a) } | 410 | 615k | } |
bytemuck::cast_slice::<u8, read_fonts::tables::colr::BaseGlyphPaint> Line | Count | Source | 408 | 161M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 161M | unsafe { internal::cast_slice(a) } | 410 | 161M | } |
bytemuck::cast_slice::<u8, read_fonts::tables::colr::Clip> Line | Count | Source | 408 | 1.61M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 1.61M | unsafe { internal::cast_slice(a) } | 410 | 1.61M | } |
bytemuck::cast_slice::<u8, read_fonts::tables::colr::Layer> Line | Count | Source | 408 | 384k | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 384k | unsafe { internal::cast_slice(a) } | 410 | 384k | } |
bytemuck::cast_slice::<u8, read_fonts::tables::colr::BaseGlyph> Line | Count | Source | 408 | 40.4M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 40.4M | unsafe { internal::cast_slice(a) } | 410 | 40.4M | } |
bytemuck::cast_slice::<u8, read_fonts::tables::colr::ColorStop> Line | Count | Source | 408 | 297k | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 297k | unsafe { internal::cast_slice(a) } | 410 | 297k | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::cpal::ColorRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::dsig::SignatureRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::feat::FeatureName> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::feat::SettingName> bytemuck::cast_slice::<u8, read_fonts::tables::fvar::VariationAxisRecord> Line | Count | Source | 408 | 1.45M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 1.45M | unsafe { internal::cast_slice(a) } | 410 | 1.45M | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::gasp::GaspRange> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::gpos::MarkRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::gpos::EntryExitRecord> bytemuck::cast_slice::<u8, read_fonts::tables::hmtx::LongMetric> Line | Count | Source | 408 | 13.5M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 13.5M | unsafe { internal::cast_slice(a) } | 410 | 13.5M | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::kerx::Subtable0Pair> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::ltag::FTStringRange> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::meta::DataMapRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::morx::Feature> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::mvar::ValueRecord> bytemuck::cast_slice::<u8, read_fonts::tables::name::NameRecord> Line | Count | Source | 408 | 485 | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 485 | unsafe { internal::cast_slice(a) } | 410 | 485 | } |
bytemuck::cast_slice::<u8, read_fonts::tables::name::LangTagRecord> Line | Count | Source | 408 | 307 | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 307 | unsafe { internal::cast_slice(a) } | 410 | 307 | } |
Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::stat::AxisRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::stat::AxisValueRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::trak::TrackTableEntry> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::varc::SparseRegionAxisCoordinates> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::vorg::VertOriginYMetrics> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::bitmap::BitmapSize> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::bitmap::BdtComponent> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::bitmap::BigGlyphMetrics> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::bitmap::GlyphIdOffsetPair> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::bitmap::SmallGlyphMetrics> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::bitmap::IndexSubtableRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::layout::RangeRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::layout::ScriptRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::layout::FeatureRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::layout::LangSysRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::layout::ClassRangeRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::layout::SequenceLookupRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::layout::FeatureVariationRecord> Unexecuted instantiation: bytemuck::cast_slice::<u8, read_fonts::tables::layout::FeatureTableSubstitutionRecord> bytemuck::cast_slice::<u8, u8> Line | Count | Source | 408 | 334M | pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] { | 409 | 334M | unsafe { internal::cast_slice(a) } | 410 | 334M | } |
Unexecuted instantiation: bytemuck::cast_slice::<_, _> |
411 | | |
412 | | /// Cast `&mut [A]` into `&mut [B]`. |
413 | | /// |
414 | | /// ## Panics |
415 | | /// |
416 | | /// This is [`try_cast_slice_mut`] but will panic on error. |
417 | | #[inline] |
418 | | #[cfg_attr(feature = "track_caller", track_caller)] |
419 | 0 | pub fn cast_slice_mut< |
420 | 0 | A: NoUninit + AnyBitPattern, |
421 | 0 | B: NoUninit + AnyBitPattern, |
422 | 0 | >( |
423 | 0 | a: &mut [A], |
424 | 0 | ) -> &mut [B] { |
425 | 0 | unsafe { internal::cast_slice_mut(a) } |
426 | 0 | } |
427 | | |
428 | | /// As [`align_to`](https://doc.rust-lang.org/std/primitive.slice.html#method.align_to), |
429 | | /// but safe because of the [`Pod`] bound. |
430 | | #[inline] |
431 | 0 | pub fn pod_align_to<T: NoUninit, U: AnyBitPattern>( |
432 | 0 | vals: &[T], |
433 | 0 | ) -> (&[T], &[U], &[T]) { |
434 | 0 | unsafe { vals.align_to::<U>() } |
435 | 0 | } |
436 | | |
437 | | /// As [`align_to_mut`](https://doc.rust-lang.org/std/primitive.slice.html#method.align_to_mut), |
438 | | /// but safe because of the [`Pod`] bound. |
439 | | #[inline] |
440 | 0 | pub fn pod_align_to_mut< |
441 | 0 | T: NoUninit + AnyBitPattern, |
442 | 0 | U: NoUninit + AnyBitPattern, |
443 | 0 | >( |
444 | 0 | vals: &mut [T], |
445 | 0 | ) -> (&mut [T], &mut [U], &mut [T]) { |
446 | 0 | unsafe { vals.align_to_mut::<U>() } |
447 | 0 | } |
448 | | |
449 | | /// Try to cast `A` into `B`. |
450 | | /// |
451 | | /// Note that for this particular type of cast, alignment isn't a factor. The |
452 | | /// input value is semantically copied into the function and then returned to a |
453 | | /// new memory location which will have whatever the required alignment of the |
454 | | /// output type is. |
455 | | /// |
456 | | /// ## Failure |
457 | | /// |
458 | | /// * If the types don't have the same size this fails. |
459 | | #[inline] |
460 | 0 | pub fn try_cast<A: NoUninit, B: AnyBitPattern>( |
461 | 0 | a: A, |
462 | 0 | ) -> Result<B, PodCastError> { |
463 | 0 | unsafe { internal::try_cast(a) } |
464 | 0 | } |
465 | | |
466 | | /// Try to convert a `&A` into `&B`. |
467 | | /// |
468 | | /// ## Failure |
469 | | /// |
470 | | /// * If the reference isn't aligned in the new type |
471 | | /// * If the source type and target type aren't the same size. |
472 | | #[inline] |
473 | 0 | pub fn try_cast_ref<A: NoUninit, B: AnyBitPattern>( |
474 | 0 | a: &A, |
475 | 0 | ) -> Result<&B, PodCastError> { |
476 | 0 | unsafe { internal::try_cast_ref(a) } |
477 | 0 | } |
478 | | |
479 | | /// Try to convert a `&mut A` into `&mut B`. |
480 | | /// |
481 | | /// As [`try_cast_ref`], but `mut`. |
482 | | #[inline] |
483 | 0 | pub fn try_cast_mut< |
484 | 0 | A: NoUninit + AnyBitPattern, |
485 | 0 | B: NoUninit + AnyBitPattern, |
486 | 0 | >( |
487 | 0 | a: &mut A, |
488 | 0 | ) -> Result<&mut B, PodCastError> { |
489 | 0 | unsafe { internal::try_cast_mut(a) } |
490 | 0 | } |
491 | | |
492 | | /// Try to convert `&[A]` into `&[B]` (possibly with a change in length). |
493 | | /// |
494 | | /// * `input.as_ptr() as usize == output.as_ptr() as usize` |
495 | | /// * `input.len() * size_of::<A>() == output.len() * size_of::<B>()` |
496 | | /// |
497 | | /// ## Failure |
498 | | /// |
499 | | /// * If the target type has a greater alignment requirement and the input slice |
500 | | /// isn't aligned. |
501 | | /// * If the target element type is a different size from the current element |
502 | | /// type, and the output slice wouldn't be a whole number of elements when |
503 | | /// accounting for the size change (eg: 3 `u16` values is 1.5 `u32` values, so |
504 | | /// that's a failure). |
505 | | /// * Similarly, you can't convert between a [ZST](https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts) |
506 | | /// and a non-ZST. |
507 | | #[inline] |
508 | 0 | pub fn try_cast_slice<A: NoUninit, B: AnyBitPattern>( |
509 | 0 | a: &[A], |
510 | 0 | ) -> Result<&[B], PodCastError> { |
511 | 0 | unsafe { internal::try_cast_slice(a) } |
512 | 0 | } |
513 | | |
514 | | /// Try to convert `&mut [A]` into `&mut [B]` (possibly with a change in |
515 | | /// length). |
516 | | /// |
517 | | /// As [`try_cast_slice`], but `&mut`. |
518 | | #[inline] |
519 | 27.3M | pub fn try_cast_slice_mut< |
520 | 27.3M | A: NoUninit + AnyBitPattern, |
521 | 27.3M | B: NoUninit + AnyBitPattern, |
522 | 27.3M | >( |
523 | 27.3M | a: &mut [A], |
524 | 27.3M | ) -> Result<&mut [B], PodCastError> { |
525 | 27.3M | unsafe { internal::try_cast_slice_mut(a) } |
526 | 27.3M | } bytemuck::try_cast_slice_mut::<u8, font_types::point::Point<font_types::fixed::Fixed>> Line | Count | Source | 519 | 615k | pub fn try_cast_slice_mut< | 520 | 615k | A: NoUninit + AnyBitPattern, | 521 | 615k | B: NoUninit + AnyBitPattern, | 522 | 615k | >( | 523 | 615k | a: &mut [A], | 524 | 615k | ) -> Result<&mut [B], PodCastError> { | 525 | 615k | unsafe { internal::try_cast_slice_mut(a) } | 526 | 615k | } |
bytemuck::try_cast_slice_mut::<u8, font_types::point::Point<font_types::fixed::F26Dot6>> Line | Count | Source | 519 | 8.12M | pub fn try_cast_slice_mut< | 520 | 8.12M | A: NoUninit + AnyBitPattern, | 521 | 8.12M | B: NoUninit + AnyBitPattern, | 522 | 8.12M | >( | 523 | 8.12M | a: &mut [A], | 524 | 8.12M | ) -> Result<&mut [B], PodCastError> { | 525 | 8.12M | unsafe { internal::try_cast_slice_mut(a) } | 526 | 8.12M | } |
Unexecuted instantiation: bytemuck::try_cast_slice_mut::<u8, font_types::point::Point<f32>> bytemuck::try_cast_slice_mut::<u8, font_types::point::Point<i32>> Line | Count | Source | 519 | 5.14M | pub fn try_cast_slice_mut< | 520 | 5.14M | A: NoUninit + AnyBitPattern, | 521 | 5.14M | B: NoUninit + AnyBitPattern, | 522 | 5.14M | >( | 523 | 5.14M | a: &mut [A], | 524 | 5.14M | ) -> Result<&mut [B], PodCastError> { | 525 | 5.14M | unsafe { internal::try_cast_slice_mut(a) } | 526 | 5.14M | } |
bytemuck::try_cast_slice_mut::<u8, read_fonts::tables::glyf::PointFlags> Line | Count | Source | 519 | 6.55M | pub fn try_cast_slice_mut< | 520 | 6.55M | A: NoUninit + AnyBitPattern, | 521 | 6.55M | B: NoUninit + AnyBitPattern, | 522 | 6.55M | >( | 523 | 6.55M | a: &mut [A], | 524 | 6.55M | ) -> Result<&mut [B], PodCastError> { | 525 | 6.55M | unsafe { internal::try_cast_slice_mut(a) } | 526 | 6.55M | } |
bytemuck::try_cast_slice_mut::<u8, i32> Line | Count | Source | 519 | 2.20M | pub fn try_cast_slice_mut< | 520 | 2.20M | A: NoUninit + AnyBitPattern, | 521 | 2.20M | B: NoUninit + AnyBitPattern, | 522 | 2.20M | >( | 523 | 2.20M | a: &mut [A], | 524 | 2.20M | ) -> Result<&mut [B], PodCastError> { | 525 | 2.20M | unsafe { internal::try_cast_slice_mut(a) } | 526 | 2.20M | } |
bytemuck::try_cast_slice_mut::<u8, u16> Line | Count | Source | 519 | 4.64M | pub fn try_cast_slice_mut< | 520 | 4.64M | A: NoUninit + AnyBitPattern, | 521 | 4.64M | B: NoUninit + AnyBitPattern, | 522 | 4.64M | >( | 523 | 4.64M | a: &mut [A], | 524 | 4.64M | ) -> Result<&mut [B], PodCastError> { | 525 | 4.64M | unsafe { internal::try_cast_slice_mut(a) } | 526 | 4.64M | } |
Unexecuted instantiation: bytemuck::try_cast_slice_mut::<_, _> |
527 | | |
528 | | /// Fill all bytes of `target` with zeroes (see [`Zeroable`]). |
529 | | /// |
530 | | /// This is similar to `*target = Zeroable::zeroed()`, but guarantees that any |
531 | | /// padding bytes in `target` are zeroed as well. |
532 | | /// |
533 | | /// See also [`fill_zeroes`], if you have a slice rather than a single value. |
534 | | #[inline] |
535 | 0 | pub fn write_zeroes<T: Zeroable>(target: &mut T) { |
536 | | struct EnsureZeroWrite<T>(*mut T); |
537 | | impl<T> Drop for EnsureZeroWrite<T> { |
538 | | #[inline(always)] |
539 | 0 | fn drop(&mut self) { |
540 | 0 | unsafe { |
541 | 0 | core::ptr::write_bytes(self.0, 0u8, 1); |
542 | 0 | } |
543 | 0 | } |
544 | | } |
545 | 0 | unsafe { |
546 | 0 | let guard = EnsureZeroWrite(target); |
547 | 0 | core::ptr::drop_in_place(guard.0); |
548 | 0 | drop(guard); |
549 | 0 | } |
550 | 0 | } |
551 | | |
552 | | /// Fill all bytes of `slice` with zeroes (see [`Zeroable`]). |
553 | | /// |
554 | | /// This is similar to `slice.fill(Zeroable::zeroed())`, but guarantees that any |
555 | | /// padding bytes in `slice` are zeroed as well. |
556 | | /// |
557 | | /// See also [`write_zeroes`], which zeroes all bytes of a single value rather |
558 | | /// than a slice. |
559 | | #[inline] |
560 | 0 | pub fn fill_zeroes<T: Zeroable>(slice: &mut [T]) { |
561 | 0 | if core::mem::needs_drop::<T>() { |
562 | 0 | // If `T` needs to be dropped then we have to do this one item at a time, in |
563 | 0 | // case one of the intermediate drops does a panic. |
564 | 0 | slice.iter_mut().for_each(write_zeroes); |
565 | 0 | } else { |
566 | | // Otherwise we can be really fast and just fill everything with zeros. |
567 | 0 | let len = slice.len(); |
568 | 0 | unsafe { core::ptr::write_bytes(slice.as_mut_ptr(), 0u8, len) } |
569 | | } |
570 | 0 | } |
571 | | |
572 | | /// Same as [`Zeroable::zeroed`], but as a `const fn` const. |
573 | | #[cfg(feature = "const_zeroed")] |
574 | | #[inline] |
575 | | #[must_use] |
576 | | pub const fn zeroed<T: Zeroable>() -> T { |
577 | | unsafe { core::mem::zeroed() } |
578 | | } |