External Publication
Visit Post

Dereferenceable Zero

Rust Internals [Unofficial] March 15, 2026
Source

In the type mapping section how do you make sure lifetimes are obeyed when mapping between the new &T and *const T?

For example it suggets mapping fn(&T) -> &U to fn(*const T) -> *const U. This is unsound.

opt-3 (speed-first) Converts only at FFI (repr(C), extern "C") and transmute boundaries. All other Option<&T> remain as-is (2 words, no niche). Recommended for bare-metal / 0x0-access code where conversion overhead or inaccessibility is undesirable

How do you know which layout a &Option<&T> is? It can come from a field of either a repr(rust) or repr(C) struct. And I can create a Vec<&Option<&T>> with mixed layouts.

Where do you save the extra word of the Option<&T>. after all:

W65C02S: 16-bit address bus spanning the full 64 KiB address space (0x0000-0xFFFF). There is not a single byte to sacrifice as a sentinel. (datasheet, pp. 5, 15)

Discussion in the ATmosphere

Loading comments...