Open
Description
Feature gate: #![feature(mem_conjure_zst)]
This is a tracking issue for the mem::conjure_zst::<T>()
function.
There are a variety of possible ways one can do this without this function, but it provides two advantages:
-
It makes it clearer to the reader what's happening and keeps the code author from needing to decide between
zeroed()
oruninitialized()
orMaybeUninit::new_uninit().assume_init()
in situations like
rust/library/alloc/src/vec/into_iter.rs
Lines 149 to 150 in ab0c2e1
-
It provides a convenient place to talk about why it's not just safe to do this in all cases.
Public API
// core::mem
pub const unsafe fn conjure_zst<T>() -> T;
Steps / History
- ACP: Add an
unsafe fn
for creating a ZST libs-team#292 (comment) - Library Implementation: Add
mem::conjure_zst
for creating ZSTs out of nothing #95385 - Lint Implementation: todo
- Final comment period (FCP)
- Stabilization PR
Unresolved Questions
- None yet.