{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreidpge2i2r3lxfmtt63bclyxv2ca7pfxe44vuvr5dfz4hrel2jbwze",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mlvpllq354a2"
  },
  "path": "/t/could-you-borrow-a-bit/24300#post_8",
  "publishedAt": "2026-05-15T14:14:55.000Z",
  "site": "https://internals.rust-lang.org",
  "tags": [
    "`BitSlice` or a sound way to implement one",
    "Unsafe Code Guidelines"
  ],
  "textContent": "I’m now noticing that the ask in this thread has large overlap with parts of the discussion in your recent previous thread: `BitSlice` or a sound way to implement one\n\nRegarding\n\nbascule:\n\n> But if the language supported mutable borrow splitting at a sub-byte granularity, then it could be possible.\n\nspecifically the last replies starting with\n\n`BitSlice` or a sound way to implement one Unsafe Code Guidelines\n\n> This is definitely only possible with language support. At the assembly level you can overwrite individual bits at a memory address with AND/ORD. But at the library level you're faced with the problem that you can't overwrite neighbouring bits you don't own, and you can't read+update them because they may be uninitialized or be being written concurrently. It sucks that seemingly no low-level language lets you manipulate data at bit-level granularity the same way you can at byte-level. (I did lo…\n\nAs far as I understand the reality of possible implementations, you’d **have** to be either restricting split mutable borrows to stay within the same thread (i.e. some degree of introducing `!Sync` or `!Send` with these types) _or_ you’d need to implement modifications of individual bits in a byte with atomic operations.",
  "title": "Could you borrow a bit?"
}