Idea / Pre-RFC: Null-free pointer and Zeroable reference
Rust Internals [Unofficial]
March 7, 2026
Relying on field projection and reborrow means this solution depends on two RFCs that are both still open experiments. If either changes direction or stalls, the entire library path disappears. This is the weakest link.
Also, ergonomics matters more than it might seem - field_definition!(S, field_name) + *field!(&mut T, field_name) vs pointer.field won't be a minor difference when you're working with dozens of struct fields.
impl<'t, Container, Field: 't> GetField<Container, Field> for &'t Container {
type Output = &'t Field;
fn get_field(self, field: FieldDefinition<Container, Field>) -> Self::Output {
unsafe { &*ptr::from_ref(self).get_field(field) }
}
}
This is an instant UB when ptr is 0x0.
Discussion in the ATmosphere