External Publication
Visit Post

`BitSlice` or a sound way to implement one

Rust Internals [Unofficial] April 24, 2026
Source

For anyone not already aware of roughly what the problem is: Rust basically has a few stable ways of supporting “higher-kinded types” (HKTs), which are families of types, like Vec (without a <T>).

Here are the three stable mechanisms for HKTs with one lifetime parameter:

  • You can denote the HKT family &'varying T with by just T, and feed the HKT a 'varying parameter to get &'varying T.
  • You can use a generic associated type (GAT) like trait GatHKT { type Apply<'varying>; }, perhaps to make a GatDeref equivalent of std’s Deref.
  • You can use higher-kinded trait bounds (like for<'varying> Trait<'varying>) to do something insane like my variance-family crate — which is thousands of lines of code long — to try to get much more thorough support for lifetime-parameterized HKTs.

Each of these three options has problems. The first isn’t fully general. The second interacts poorly with higher-kinded trait bounds. The third involves several unsafe traits and presumably isn’t fit for std.

std uses the first option, which means its traits aren’t as general as possible.

Discussion in the ATmosphere

Loading comments...