{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreicxudccqxbokheshjlnfz3bjykdy35v2hj254jj5yfq62irm4i32u",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mlhd6ugo4gn2"
  },
  "path": "/t/include-racy-reads-in-rust-memory-model-with-maybeinvalid-t/24289#post_2",
  "publishedAt": "2026-05-09T22:24:23.000Z",
  "site": "https://internals.rust-lang.org",
  "tags": [
    "comment"
  ],
  "textContent": "Writing this post gave me the idea of replacing `AtomicPerByte` for RFC 3301 by\n\n\n    struct AtomicCell<T>(UnsafeCell<T>);\n\n    unsafe impl<T: Send> Sync for AtomicCell<T> {}\n\n    impl<T> AtomicCell<T> {\n        pub const fn new(value: T) -> Self { Self(UnsafeCell::new(value)) }\n        /// Safety\n        ///\n        /// Calls to `store` must be serialized,\n        /// i.e. two thread shall not call `store` concurrently.\n        pub unsafe fn store(&self, value: T, ordering: Ordering) { /* .. */ }\n        pub fn load(&self, ordering: Ordering) -> MaybeUninit<T> { /* .. */ }\n        pub const fn get_mut(&mut self) -> &mut T { self.0.get_mut() }\n        pub const fn as_ptr(&self) -> *mut T { self.0.get() }\n    }\n\n\nIt keeps the biggest advantage of the `MaybeInvalid` proposal, i.e. no torn writes, i.e. no drop issue, while not requiring the memory model to be modified. The proposal is written in a comment to RFC 3301.\n\nSo now my issues about `AtomicPerByte` are solved with `AtomicCell`, I have less interest into this `MaybeInvalid` proposal.",
  "title": "Include racy reads in Rust memory model with `MaybeInvalid<T>`"
}