Function nom::lib::std::mem::zeroed1.0.0[][src]

pub unsafe fn zeroed<T>() -> T

Creates a value whose bytes are all zero.

This has the same effect as allocating space with mem::uninitialized and then zeroing it out. It is useful for FFI sometimes, but should generally be avoided.

There is no guarantee that an all-zero byte-pattern represents a valid value of some type T. If T has a destructor and the value is destroyed (due to a panic or the end of a scope) before being initialized, then the destructor will run on zeroed data, likely leading to undefined behavior.

See also the documentation for mem::uninitialized, which has many of the same caveats.

Examples

use std::mem;

let x: i32 = unsafe { mem::zeroed() };
assert_eq!(0, x);