This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
decl_event!
should generate only one struct/typeΒ #4288
Copy link
Copy link
Closed
Labels
I7-refactorCode needs refactoring.Code needs refactoring.Z2-mediumCan be fixed by a coder with good Rust knowledge but little knowledge of the codebase.Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.Z6-mentorAn easy task where a mentor is available. Please indicate in the issue who the mentor could be.An easy task where a mentor is available. Please indicate in the issue who the mentor could be.
Milestone
Description
Currently decl_event!
creates enum RawEvent
and type Event =
when you have a generic event, but for none-generic events it just generates enum Event
.
This needs to be unified, aka just generate enum Event
.
As rust automatic trait derives are somewhat broken, the macro will need to implementClone
, PartialEq
, Eq
and RuntimeDebug
on it's own. It is required that trait bound will not be put onto the generic parameter itself and instead it needs to be put onto the associated types, so something like this:
enum Event<T> {
SomeEvent(T::Data),
}
has the following PartialEq
bounds:
impl<T: Trait> PartialEq for Event<T> where T::Data: PartialEq
and not:
impl<T: Trait> PartialEq for Event<T> where T: PartialEq
parity-scale-codec
does this already automatic and so derive(Encode, Decode)
should work without any problems.
The code of the macro can be found here
jakubadamw, shawntabrizi and liuchengxu
Metadata
Metadata
Assignees
Labels
I7-refactorCode needs refactoring.Code needs refactoring.Z2-mediumCan be fixed by a coder with good Rust knowledge but little knowledge of the codebase.Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.Z6-mentorAn easy task where a mentor is available. Please indicate in the issue who the mentor could be.An easy task where a mentor is available. Please indicate in the issue who the mentor could be.