{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiejgoszgqwgxmsudppvgfiw7hpvbnm5ldigoeunmhkhzthyl2uzny",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mmhd4ohqit22"
},
"path": "/t/another-experiment-to-make-unsafe-rust-safer-preventing-ub-in-maybeuninit-with-compile-time-error/24352#post_3",
"publishedAt": "2026-05-22T13:27:34.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "I do not understand what do you mean yet, may you elaborate more?\n\nIn this guard, the goal is to prevent calling assume_init if it is uninitialized, because it is UB. The compile time error will tell us to call .write first, so that it is initialized and safe to use\n\nSame to the above, it also prevents taking reference and pointer, because reading or writing uninit memory is UB\n\nThe point of this guard is to make using uninitialized memory safer by preventing calling assume_init, reading, and writing to it while the memory is still uninit. `Option<MaybeUninit<T>>` does not prevent calling assume_init, or taking reference or pointer then reading or writing to uninit MaybeUninit\n\n`Option<T>` does not has corelation because it is not uninitialized memory. The point of using uninit memory is to avoid the process of first init\n\nAfter .write is called, the guard goal is success, no guard is needed because now the memory is initialized and can be used freely and safely",
"title": "Another Experiment To Make Unsafe Rust Safer: Preventing UB In MaybeUninit With Compile Time Error"
}