External Publication
Visit Post

`BitSlice` or a sound way to implement one

Rust Internals [Unofficial] May 2, 2026
Source

I would really like to just have a u1 type where Vec<u1> and [u1] behave as you'd expect. For this to be possible without breaking everything you'd need at least:

  • A new BitSized built-in trait where Sized: BitSized.
  • For u1 to not implement Sized (because it doesn't have a size expressible in bytes).
  • To relax the bounds on Vec<T> and [T] to just be T: BitSized.

I don't know how feasible this is on the codegen side of things though, eg. if you have two &mut [u1] that overlap the same byte.

Discussion in the ATmosphere

Loading comments...