Function std::mem::uninitializedStable [-] [+] [src]

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

Create an uninitialized value.

Care must be taken when using this function, if the type T has a destructor and the value falls out of scope (due to unwinding or returning) before being initialized, then the destructor will run on uninitialized data, likely leading to crashes.

This is useful for FFI functions sometimes, but should generally be avoided.

Examples

fn main() { use std::mem; let x: i32 = unsafe { mem::uninitialized() }; }
use std::mem;

let x: i32 = unsafe { mem::uninitialized() };