-
Notifications
You must be signed in to change notification settings - Fork 139
Open
Description
Ignore zero-width fields to allow complier hinting with types like PhantomData
while deriving trait imlementations.
// This should work.
#[derive(derive_more::Add)]
struct A<B>(u16, PhantomData<B>);
// Equivalent to:
impl<B> Add for A<B> {
type Output = Self;
fn add(self, rhs: Self) -> Self::Output {
Self(self.0 + rhs.0, PhantomData)
}
}
This behavior can be seen in #[repr(transparent)]
, where the annotation will work as long as there is only one non-zero-width type.