mirror of
https://github.com/Lokathor/bytemuck.git
synced 2024-11-25 00:02:22 +00:00
use the correct (weaker) trait bound.
This commit is contained in:
parent
9f29a253b2
commit
a2baf0abb3
@ -85,7 +85,9 @@ pub fn zeroed_box<T: Zeroable>() -> Box<T> {
|
|||||||
///
|
///
|
||||||
/// This fails if the allocation fails.
|
/// This fails if the allocation fails.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn try_zeroed_slice_box<T: Pod>(length: usize) -> Result<Box<[T]>, ()> {
|
pub fn try_zeroed_slice_box<T: Zeroable>(
|
||||||
|
length: usize,
|
||||||
|
) -> Result<Box<[T]>, ()> {
|
||||||
if size_of::<T>() == 0 {
|
if size_of::<T>() == 0 {
|
||||||
// This will not allocate but simple create a dangling slice pointer.
|
// This will not allocate but simple create a dangling slice pointer.
|
||||||
let mut vec = Vec::with_capacity(length);
|
let mut vec = Vec::with_capacity(length);
|
||||||
@ -113,7 +115,7 @@ pub fn try_zeroed_slice_box<T: Pod>(length: usize) -> Result<Box<[T]>, ()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// As [`try_zeroed_slice_box`](try_zeroed_slice_box), but unwraps for you.
|
/// As [`try_zeroed_slice_box`](try_zeroed_slice_box), but unwraps for you.
|
||||||
pub fn zeroed_slice_box<T: Pod>(length: usize) -> Box<[T]> {
|
pub fn zeroed_slice_box<T: Zeroable>(length: usize) -> Box<[T]> {
|
||||||
try_zeroed_slice_box(length).unwrap()
|
try_zeroed_slice_box(length).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user