{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreihif5qomvja554uqvx2sdjsssk4vkhls5srelddhptmjtasjdxhka",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mmhd4jm4qp32"
},
"path": "/t/another-experiment-to-make-unsafe-rust-safer-preventing-ub-in-maybeuninit-with-compile-time-error/24352#post_4",
"publishedAt": "2026-05-22T15:04:17.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"Initializing an array element-by-element",
"Initializing a struct field-by-field"
],
"textContent": "In every program where it is possible to call your version of `write()`, which moves the \"storage\" and returns a new value of a different type, it is possible, and simpler, to not use `MaybeUninit` at all.\n\n`MaybeUninit` is used in situations where\n\n * the storage must not be moved, or\n * the memory becomes initialized a piece at a time, not all at once (like the examples in `MaybeUninit`'s documentation: Initializing an array element-by-element and Initializing a struct field-by-field).\n\n\n\nThese things cannot be implemented using your `write()`.",
"title": "Another Experiment To Make Unsafe Rust Safer: Preventing UB In MaybeUninit With Compile Time Error"
}