You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@raklaptudirm since Rust doesn't have any compile-time reflection, we cannot know whether a type is zero-sized during macro expansion. Of course, we can try to match them by name, but that will break shortly if the type is aliased by an unknown name for us.
What we can do instead, is to allow user specifying that:
#[derive(derive_more::Add)]structA<B>(u16,#[add(skip)]PhantomData<B>);// will expand to:impl<B>AddforA<B>{typeOutput = Self;fnadd(self,rhs:Self) -> Self::Output{Self(self.0 + rhs.0,self.1)}}
Ignore zero-width fields to allow complier hinting with types like
PhantomData
while deriving trait imlementations.This behavior can be seen in
#[repr(transparent)]
, where the annotation will work as long as there is only one non-zero-width type.The text was updated successfully, but these errors were encountered: