How is NonZeroU32 different than a newtype?
Looking at the source for std::num::NonZeroU32 shows that it's defined as
#[repr(transparent)]
pub struct NonZeroU32(u32);
and the get method is just an inline self.0. Why, then, does the compiler treat them differently?
I don't really know assembly, but it looks to me like the compiler is recognizing that unwrapping NonZeroU32 is a no-op, and I'm guessing the few instructions remaining are just setting the stack to return from the function. On the other hand, unwrapping a newtype produces a lot more assembly. I'm not sure what that assembly is doing, but why would it be different in the first place?