Could you borrow a bit?
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
Regarding
bascule:
But if the language supported mutable borrow splitting at a sub-byte granularity, then it could be possible.
specifically the last replies starting with
BitSlice or a sound way to implement one Unsafe Code Guidelines
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…
As 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.
Discussion in the ATmosphere