External Publication
Visit Post

Could you borrow a bit?

Rust Internals [Unofficial] May 15, 2026
Source

The type family &mut T with T: Sized definitionally relies on the meaning of size_of::<T> for the underlying aliased memory region. So that's pretty much out or at the very least requires you to internally point to the type as UnsafeCell<u8> and so unfortunately the type will lose all noalias benefits.

What's disappointing here is that it does not compose well with other independent references, i.e. since shared references are used to represent a unique one none of the builtin projection interfaces would work well here.

Also, if we consider representing full bitfields with an additional width property instead of or mixed in with single bits note that for the dynamic variant all pointer metadata must implement Ord; but how do you properly sort usize×usize? Probably tuple sorting where the start is compared first and the length only on mismatch (it's weird though, as an analogue is there an ordering relationship between all pointers to slices? we even have lint for this ambiguous_wide_pointer_comparisons).

Discussion in the ATmosphere

Loading comments...