# 1.0.0[−][src]Function core::mem::uninitialized

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

Deprecated since 1.39.0:

use `mem::MaybeUninit` instead

Bypasses Rust's normal memory-initialization checks by pretending to produce a value of type `T`, while doing nothing at all.

This function is deprecated. Use `MaybeUninit<T>` instead.

The reason for deprecation is that the function basically cannot be used correctly: the Rust compiler assumes that values are properly initialized. As a consequence, calling e.g. `mem::uninitialized::<bool>()` causes immediate undefined behavior for returning a `bool` that is not definitely either `true` or `false`. Worse, truly uninitialized memory like what gets returned here is special in that the compiler knows that it does not have a fixed value. This makes it undefined behavior to have uninitialized data in a variable even if that variable has an integer type. (Notice that the rules around uninitialized integers are not finalized yet, but until they are, it is advisable to avoid them.)

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)