Idea: Would Rust benefit from explicitly polymorphic generics?

To be more specific, consider Example<'_, u16, u16>.

Today, that can't have get_raw_ptr(p1) == null and can't have get_raw_ptr(p2) == null. But with that RFC, layout calculation could also take advantage of the fact that it can't have get_raw_ptr(p1) == 1 nor get_raw_ptr(p1) == 1 either, since u16 is 2-aligned (assuming you're on one of the vast majority of platforms where it's 2-aligned, at least).

So then things that take advantage of niche optimizations -- like options -- might make different choices given that additional freedom.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.