Stabilize offset_of_slice by jdonszelmann · Pull Request #139673 · rust-lang/rust (original) (raw)

Tracking issue: #126151

This stabilizes using offset_of! for dynamically sized fields (i.e. the last field of a DST) which are a slice or a wrapper around a slice. If the field is, for example, dyn Trait we cannot know ifs offset, because the offset can depend on the alignment of the underlying type. But if the dynamically sized field is a slice, the alignment is constant and the offset of that field can be calculated.

There did not seem to be any problems with the implementation of this feature, and no known issues. Discussed with @WaffleLapkin to move for stabilization. I updated the documentation for the offset_of!().

r? @RalfJung