ialloc/boxed/abox_bytemuck.rs
1use crate::boxed::ABox;
2use crate::error::ExcessiveSliceRequestedError;
3use crate::fat::*;
4use crate::meta::*;
5use crate::util;
6
7use bytemuck::*;
8
9use core::alloc::Layout;
10
11
12
13impl<T: Zeroable, A: Alloc + Free> ABox<T, A> {
14 // Sized, Alloc
15
16 /// Allocate a new box initialized to `0` using `allocator`.
17 ///
18 /// ## Failure Modes
19 /// * Fails to compile on impossible alignments (e.g. attempting to allocate 4 KiB alignment pages via 8/16 byte aligned malloc)
20 /// * Fails to compile for ZSTs if unsupported by the allocator
21 /// * Returns <code>[Err]\(...\)</code> when out of memory
22 ///
23 /// ## Examples
24 /// ```
25 /// use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
26 /// let a = ABox::<u32, _>::try_new_bytemuck_zeroed_in(Malloc).unwrap();
27 /// let a = ABox::<(), _>::try_new_bytemuck_zeroed_in(DangleZst(Malloc)).unwrap();
28 /// ```
29 ///
30 /// ```
31 /// // will return Err(...) - Null can't allocate anything
32 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
33 /// let err = ABox::<u32, _>::try_new_bytemuck_zeroed_in(Null).unwrap_err();
34 /// ```
35 ///
36 /// ```compile_fail,E0080
37 /// // won't compile - Malloc doesn't support ZSTs
38 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
39 /// let a = ABox::<(), _>::try_new_bytemuck_zeroed_in(Malloc).unwrap();
40 /// ```
41 ///
42 /// ```compile_fail,E0080
43 /// // won't compile - Malloc doesn't support Page alignment
44 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
45 /// #[repr(C, align(4096))] pub struct Page([u8; 4096]);
46 /// unsafe impl bytemuck::Zeroable for Page {}
47 /// let a = ABox::<Page, _>::try_new_bytemuck_zeroed_in(Malloc).unwrap();
48 /// ```
49 #[track_caller] pub fn try_new_bytemuck_zeroed_in(allocator: A) -> Result<Self, A::Error> {
50 let _ = Self::ASSERT_A_CAN_ALLOC_T;
51 let layout = Layout::new::<T>();
52 let data = allocator.alloc_zeroed(layout)?.cast();
53 // SAFETY: ✔️ we just allocated `data` with `allocator`
54 // SAFETY: ✔️ `T` is `Zeroable`, so our `alloc_zeroed` should've made `*data` a valid initialized `T`
55 Ok(unsafe { ABox::from_raw_in(data, allocator) })
56 }
57
58 /// Allocate a new box of `len` values initialized to `0` using `allocator`.
59 ///
60 /// ## Failure Modes
61 /// * Fails to compile on impossible alignments (e.g. attempting to allocate 4 KiB alignment pages via 8/16 byte aligned malloc)
62 /// * Fails to compile if the allocator doesn't support ZSTs
63 /// * Returns <code>[Err]\(...\)</code> when excessively large allocations are requested
64 /// * Returns <code>[Err]\(...\)</code> when out of memory
65 ///
66 /// ## Examples
67 /// ```
68 /// use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
69 /// let alloc = DangleZst(Malloc);
70 /// let a = ABox::<u32, _>::try_new_bytemuck_zeroed_slice_in(0, alloc).unwrap();
71 /// # assert_eq!(a.len(), 0);
72 /// let a = ABox::<(), _>::try_new_bytemuck_zeroed_slice_in(0, alloc).unwrap();
73 /// # assert_eq!(a.len(), 0);
74 /// let a = ABox::<u32, _>::try_new_bytemuck_zeroed_slice_in(32, alloc).unwrap();
75 /// # assert_eq!(a.len(), 32);
76 /// let a = ABox::<(), _>::try_new_bytemuck_zeroed_slice_in(32, alloc).unwrap();
77 /// # assert_eq!(a.len(), 32);
78 /// let a = ABox::<(), _>::try_new_bytemuck_zeroed_slice_in(usize::MAX, alloc).unwrap();
79 /// # assert_eq!(a.len(), usize::MAX);
80 /// ```
81 ///
82 /// ```
83 /// // will return Err(...) - too much memory requested
84 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
85 /// # let alloc = DangleZst(Malloc);
86 /// let err = ABox::<u32, _>::try_new_bytemuck_zeroed_slice_in(usize::MAX, alloc).err().unwrap();
87 /// ```
88 ///
89 /// ```
90 /// // will return Err(...) - still too much memory (half the address space → `Layout` overflows)
91 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
92 /// # let alloc = DangleZst(Malloc);
93 /// let err = ABox::<u32, _>::try_new_bytemuck_zeroed_slice_in(usize::MAX/8+1, alloc).err().unwrap();
94 /// ```
95 ///
96 /// ```compile_fail,E0277
97 /// // won't compile - Malloc doesn't support ZSTs like empty slices
98 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
99 /// let a = ABox::<u32, _>::try_new_bytemuck_zeroed_slice_in(0, Malloc).unwrap();
100 /// ```
101 ///
102 /// ```compile_fail,E0080
103 /// // won't compile - Malloc doesn't support Page alignment
104 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
105 /// # let alloc = DangleZst(Malloc);
106 /// #[repr(C, align(4096))] pub struct Page([u8; 4096]);
107 /// unsafe impl bytemuck::Zeroable for Page {}
108 /// let a = ABox::<Page, _>::try_new_bytemuck_zeroed_slice_in(1, alloc).unwrap();
109 /// ```
110 #[track_caller] pub fn try_new_bytemuck_zeroed_slice_in(len: usize, allocator: A) -> Result<ABox<[T], A>, A::Error> where A : ZstSupported {
111 let _ = Self::ASSERT_A_CAN_ALLOC_T_SLICE;
112 let layout = Layout::array::<T>(len).map_err(|_| ExcessiveSliceRequestedError{ requested: len })?;
113 let data = util::nn::slice_from_raw_parts(allocator.alloc_zeroed(layout)?.cast(), len);
114 // SAFETY: ✔️ we just allocated `data` with `allocator`
115 // SAFETY: ✔️ `T` is `Zeroable`, so our `alloc_zeroed` should've made `*data` a valid initialized `[T; len]`
116 Ok(unsafe { ABox::from_raw_in(data, allocator) })
117 }
118
119 /// Allocate a new box initialized to `0` using `allocator`.
120 ///
121 /// ## Failure Modes
122 /// * Fails to compile on impossible alignments (e.g. attempting to allocate 4 KiB alignment pages via 8/16 byte aligned malloc)
123 /// * Fails to compile for ZSTs if unsupported by the allocator
124 /// * [`panic!`]s or [`handle_alloc_error`](alloc::alloc::handle_alloc_error)s when out of memory
125 ///
126 /// ## Examples
127 /// ```
128 /// use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
129 /// let a = ABox::<u32, _>::new_bytemuck_zeroed_in(Malloc);
130 /// let a = ABox::<(), _>::new_bytemuck_zeroed_in(DangleZst(Malloc));
131 /// ```
132 ///
133 /// ```should_panic
134 /// // will panic - Null can't allocate anything
135 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
136 /// let a = ABox::<u32, _>::new_bytemuck_zeroed_in(Null);
137 /// ```
138 ///
139 /// ```compile_fail,E0080
140 /// // won't compile - Malloc doesn't support ZSTs
141 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
142 /// let a = ABox::<(), _>::new_bytemuck_zeroed_in(Malloc);
143 /// ```
144 ///
145 /// ```compile_fail,E0080
146 /// // won't compile - Malloc doesn't support Page alignment
147 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
148 /// #[repr(C, align(4096))] pub struct Page([u8; 4096]);
149 /// unsafe impl bytemuck::Zeroable for Page {}
150 /// let a = ABox::<Page, _>::new_bytemuck_zeroed_in(Malloc);
151 /// ```
152 #[cfg(global_oom_handling)] #[track_caller] pub fn new_bytemuck_zeroed_in(allocator: A) -> Self {
153 let _ = Self::ASSERT_A_CAN_ALLOC_T;
154 Self::try_new_bytemuck_zeroed_in(allocator).expect("unable to allocate")
155 }
156
157 /// Allocate a new box of `len` values initialized to `0` using `allocator`.
158 ///
159 /// ## Failure Modes
160 /// * Fails to compile on impossible alignments (e.g. attempting to allocate 4 KiB alignment pages via 8/16 byte aligned malloc)
161 /// * Fails to compile if the allocator doesn't support ZSTs
162 /// * [`panic!`]s or [`handle_alloc_error`](alloc::alloc::handle_alloc_error)s when excessively large allocations are requested
163 /// * [`panic!`]s or [`handle_alloc_error`](alloc::alloc::handle_alloc_error)s when out of memory
164 ///
165 /// ## Examples
166 /// ```
167 /// use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
168 /// let alloc = DangleZst(Malloc);
169 /// let a = ABox::<u32, _>::new_bytemuck_zeroed_slice_in(0, alloc);
170 /// # assert_eq!(a.len(), 0);
171 /// let a = ABox::<(), _>::new_bytemuck_zeroed_slice_in(0, alloc);
172 /// # assert_eq!(a.len(), 0);
173 /// let a = ABox::<u32, _>::new_bytemuck_zeroed_slice_in(32, alloc);
174 /// # assert_eq!(a.len(), 32);
175 /// let a = ABox::<(), _>::new_bytemuck_zeroed_slice_in(32, alloc);
176 /// # assert_eq!(a.len(), 32);
177 /// let a = ABox::<(), _>::new_bytemuck_zeroed_slice_in(usize::MAX, alloc);
178 /// # assert_eq!(a.len(), usize::MAX);
179 /// ```
180 ///
181 /// ```should_panic
182 /// // will panic - too much memory requested
183 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
184 /// # let alloc = DangleZst(Malloc);
185 /// let a = ABox::<u32, _>::new_bytemuck_zeroed_slice_in(usize::MAX, alloc);
186 /// ```
187 ///
188 /// ```should_panic
189 /// // will panic - still too much memory (half the address space → `Layout` overflows)
190 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
191 /// # let alloc = DangleZst(Malloc);
192 /// let a = ABox::<u32, _>::new_bytemuck_zeroed_slice_in(usize::MAX/8+1, alloc);
193 /// ```
194 ///
195 /// ```compile_fail,E0277
196 /// // won't compile - Malloc doesn't support ZSTs like empty slices
197 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
198 /// let a = ABox::<u32, _>::new_bytemuck_zeroed_slice_in(0, Malloc);
199 /// ```
200 ///
201 /// ```compile_fail,E0080
202 /// // won't compile - Malloc doesn't support Page alignment
203 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
204 /// # let alloc = DangleZst(Malloc);
205 /// #[repr(C, align(4096))] pub struct Page([u8; 4096]);
206 /// unsafe impl bytemuck::Zeroable for Page {}
207 /// let a = ABox::<Page, _>::new_bytemuck_zeroed_slice_in(1, alloc);
208 /// ```
209 #[cfg(global_oom_handling)] #[track_caller] pub fn new_bytemuck_zeroed_slice_in(len: usize, allocator: A) -> ABox<[T], A> where A : ZstSupported {
210 let _ = Self::ASSERT_A_CAN_ALLOC_T_SLICE;
211 Self::try_new_bytemuck_zeroed_slice_in(len, allocator).expect("unable to allocate")
212 }
213}
214
215impl<T: Zeroable, A: Alloc + Free + Default> ABox<T, A> {
216 // Sized, Alloc, Default
217
218 /// Allocate a new box initialized to `0`.
219 ///
220 /// ## Failure Modes
221 /// * Fails to compile on impossible alignments (e.g. attempting to allocate 4 KiB alignment pages via 8/16 byte aligned malloc)
222 /// * Fails to compile for ZSTs if unsupported by the allocator
223 /// * Returns <code>[Err]\(...\)</code> when out of memory
224 ///
225 /// ## Examples
226 /// ```
227 /// use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
228 /// let a = ABox::<u32, Malloc>::try_new_bytemuck_zeroed().unwrap();
229 /// let a = ABox::<(), DangleZst<Malloc>>::try_new_bytemuck_zeroed().unwrap();
230 /// ```
231 ///
232 /// ```
233 /// // will return Err(...) - Null can't allocate anything
234 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
235 /// let err = ABox::<u32, Null>::try_new_bytemuck_zeroed().unwrap_err();
236 /// ```
237 ///
238 /// ```compile_fail,E0080
239 /// // won't compile - Malloc doesn't support ZSTs
240 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
241 /// let a = ABox::<(), Malloc>::try_new_bytemuck_zeroed().unwrap();
242 /// ```
243 ///
244 /// ```compile_fail,E0080
245 /// // won't compile - Malloc doesn't support Page alignment
246 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
247 /// #[repr(C, align(4096))] pub struct Page([u8; 4096]);
248 /// unsafe impl bytemuck::Zeroable for Page {}
249 /// let a = ABox::<Page, Malloc>::try_new_bytemuck_zeroed().unwrap();
250 /// ```
251 #[track_caller] #[inline(always)] pub fn try_new_bytemuck_zeroed() -> Result<Self, A::Error> {
252 let _ = Self::ASSERT_A_CAN_ALLOC_T;
253 Self::try_new_bytemuck_zeroed_in(A::default())
254 }
255
256 /// Allocate a new box of `len` values initialized to `0`.
257 ///
258 /// ## Failure Modes
259 /// * Fails to compile on impossible alignments (e.g. attempting to allocate 4 KiB alignment pages via 8/16 byte aligned malloc)
260 /// * Fails to compile if the allocator doesn't support ZSTs
261 /// * Returns <code>[Err]\(...\)</code> when excessively large allocations are requested
262 /// * Returns <code>[Err]\(...\)</code> when out of memory
263 ///
264 /// ## Examples
265 /// ```
266 /// use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
267 /// type A = DangleZst<Malloc>;
268 /// let a = ABox::<u32, A>::try_new_bytemuck_zeroed_slice(0).unwrap();
269 /// # assert_eq!(a.len(), 0);
270 /// let a = ABox::<(), A>::try_new_bytemuck_zeroed_slice(0).unwrap();
271 /// # assert_eq!(a.len(), 0);
272 /// let a = ABox::<u32, A>::try_new_bytemuck_zeroed_slice(32).unwrap();
273 /// # assert_eq!(a.len(), 32);
274 /// let a = ABox::<(), A>::try_new_bytemuck_zeroed_slice(32).unwrap();
275 /// # assert_eq!(a.len(), 32);
276 /// let a = ABox::<(), A>::try_new_bytemuck_zeroed_slice(usize::MAX).unwrap();
277 /// # assert_eq!(a.len(), usize::MAX);
278 /// ```
279 ///
280 /// ```
281 /// // will return Err(...) - too much memory requested
282 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
283 /// # type A = DangleZst<Malloc>;
284 /// let err = ABox::<u32, A>::try_new_bytemuck_zeroed_slice(usize::MAX).err().unwrap();
285 /// ```
286 ///
287 /// ```
288 /// // will return Err(...) - still too much memory (half the address space → `Layout` overflows)
289 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
290 /// # type A = DangleZst<Malloc>;
291 /// let err = ABox::<u32, A>::try_new_bytemuck_zeroed_slice(usize::MAX/8+1).err().unwrap();
292 /// ```
293 ///
294 /// ```compile_fail,E0277
295 /// // won't compile - Malloc doesn't support ZSTs like empty slices
296 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
297 /// let a = ABox::<u32, Malloc>::try_new_bytemuck_zeroed_slice(0).unwrap();
298 /// ```
299 ///
300 /// ```compile_fail,E0080
301 /// // won't compile - Malloc doesn't support Page alignment
302 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
303 /// # type A = DangleZst<Malloc>;
304 /// #[repr(C, align(4096))] pub struct Page([u8; 4096]);
305 /// unsafe impl bytemuck::Zeroable for Page {}
306 /// let a = ABox::<Page, A>::try_new_bytemuck_zeroed_slice(1).unwrap();
307 /// ```
308 #[track_caller] #[inline(always)] pub fn try_new_bytemuck_zeroed_slice(len: usize) -> Result<ABox<[T], A>, A::Error> where A : ZstSupported {
309 let _ = Self::ASSERT_A_CAN_ALLOC_T_SLICE;
310 Self::try_new_bytemuck_zeroed_slice_in(len, A::default())
311 }
312
313 /// Allocate a new box initialized to `0`.
314 ///
315 /// ## Failure Modes
316 /// * Fails to compile on impossible alignments (e.g. attempting to allocate 4 KiB alignment pages via 8/16 byte aligned malloc)
317 /// * Fails to compile for ZSTs if unsupported by the allocator
318 /// * [`panic!`]s or [`handle_alloc_error`](alloc::alloc::handle_alloc_error)s when out of memory
319 ///
320 /// ## Examples
321 /// ```
322 /// use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
323 /// let a = ABox::<u32, Malloc>::new_bytemuck_zeroed();
324 /// let a = ABox::<(), DangleZst<Malloc>>::new_bytemuck_zeroed();
325 /// ```
326 ///
327 /// ```should_panic
328 /// // will panic - Null can't allocate anything
329 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
330 /// let a = ABox::<u32, Null>::new_bytemuck_zeroed();
331 /// ```
332 ///
333 /// ```compile_fail,E0080
334 /// // won't compile - Malloc doesn't support ZSTs
335 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
336 /// let a = ABox::<(), Malloc>::new_bytemuck_zeroed();
337 /// ```
338 ///
339 /// ```compile_fail,E0080
340 /// // won't compile - Malloc doesn't support Page alignment
341 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
342 /// #[repr(C, align(4096))] pub struct Page([u8; 4096]);
343 /// unsafe impl bytemuck::Zeroable for Page {}
344 /// let a = ABox::<Page, Malloc>::new_bytemuck_zeroed();
345 /// ```
346 #[cfg(global_oom_handling)] #[track_caller] #[inline(always)] pub fn new_bytemuck_zeroed() -> Self {
347 let _ = Self::ASSERT_A_CAN_ALLOC_T;
348 Self::new_bytemuck_zeroed_in(A::default())
349 }
350
351 /// Allocate a new box of `len` values initialized to `0`.
352 ///
353 /// ## Failure Modes
354 /// * Fails to compile on impossible alignments (e.g. attempting to allocate 4 KiB alignment pages via 8/16 byte aligned malloc)
355 /// * Fails to compile if the allocator doesn't support ZSTs
356 /// * [`panic!`]s or [`handle_alloc_error`](alloc::alloc::handle_alloc_error)s when excessively large allocations are requested
357 /// * [`panic!`]s or [`handle_alloc_error`](alloc::alloc::handle_alloc_error)s when out of memory
358 ///
359 /// ## Examples
360 /// ```
361 /// use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
362 /// type A = DangleZst<Malloc>;
363 /// let a = ABox::<u32, A>::new_bytemuck_zeroed_slice(0);
364 /// # assert_eq!(a.len(), 0);
365 /// let a = ABox::<(), A>::new_bytemuck_zeroed_slice(0);
366 /// # assert_eq!(a.len(), 0);
367 /// let a = ABox::<u32, A>::new_bytemuck_zeroed_slice(32);
368 /// # assert_eq!(a.len(), 32);
369 /// let a = ABox::<(), A>::new_bytemuck_zeroed_slice(32);
370 /// # assert_eq!(a.len(), 32);
371 /// let a = ABox::<(), A>::new_bytemuck_zeroed_slice(usize::MAX);
372 /// # assert_eq!(a.len(), usize::MAX);
373 /// ```
374 ///
375 /// ```should_panic
376 /// // will panic - too much memory requested
377 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
378 /// # type A = DangleZst<Malloc>;
379 /// let a = ABox::<u32, A>::new_bytemuck_zeroed_slice(usize::MAX);
380 /// ```
381 ///
382 /// ```should_panic
383 /// // will panic - still too much memory (half the address space → `Layout` overflows)
384 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
385 /// # type A = DangleZst<Malloc>;
386 /// let a = ABox::<u32, A>::new_bytemuck_zeroed_slice(usize::MAX/8+1);
387 /// ```
388 ///
389 /// ```compile_fail,E0277
390 /// // won't compile - Malloc doesn't support ZSTs like empty slices
391 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
392 /// let a = ABox::<u32, Malloc>::new_bytemuck_zeroed_slice(0);
393 /// ```
394 ///
395 /// ```compile_fail,E0080
396 /// // won't compile - Malloc doesn't support Page alignment
397 /// # use ialloc::{allocator::{adapt::DangleZst, c::Malloc, debug::Null}, boxed::ABox};
398 /// # type A = DangleZst<Malloc>;
399 /// #[repr(C, align(4096))] pub struct Page([u8; 4096]);
400 /// unsafe impl bytemuck::Zeroable for Page {}
401 /// let a = ABox::<Page, A>::new_bytemuck_zeroed_slice(1);
402 /// ```
403 #[cfg(global_oom_handling)] #[track_caller] #[inline(always)] pub fn new_bytemuck_zeroed_slice(len: usize) -> ABox<[T], A> where A : ZstSupported {
404 let _ = Self::ASSERT_A_CAN_ALLOC_T_SLICE;
405 Self::new_bytemuck_zeroed_slice_in(len, A::default())
406 }
407}