Function constmuck::zeroed[][src]

pub const fn zeroed<T, const SIZE: usize>(
    _bounds: TypeSize<ImplsZeroable<T>, T, SIZE>
) -> T
Expand description

For safely getting a std::mem::zeroed T.

This function requires that T implements Zeroable.

Example

use constmuck::{zeroed, type_size};

const BYTES: [u8; 4] = zeroed(type_size!([u8; 4]));
const CHARS: [char; 4] = zeroed(type_size!([char; 4]));

assert_eq!(BYTES, [0, 0, 0, 0]);
assert_eq!(CHARS, ['\0', '\0', '\0', '\0']);