swarm-derive/: Add where clause of behaviour to generated out event#2819
swarm-derive/: Add where clause of behaviour to generated out event#2819mxinden merged 2 commits intolibp2p:masterfrom
Conversation
When generating the `OutEvent` for a `NetworkBehaviour`, add the `where` clause of the `NetworkBehaviour` `struct` to the generated `enum`.
|
Won't this cause an error in case of #[derive(NetworkBehaviour)]
struct Foo<T>
where
T: Copy
{
ping: libp2p::ping::Ping,
#[behaviour(ignore)]
bar: T,
}which will generate pub enum FooEvent<T> // Error: unused Parameter
where
T: Copy
{
Ping(<libp2p::ping::Ping as NetworkBehaviour>::OutEvent)
}Am I missing something? |
|
@elenaf9 that is correct. Good catch. Though why would someone use the Once we remove With that in mind, I would leave this as is. Do you agree @elenaf9? |
I am a bit confused. Why would we not need
@mxinden what am I missing here? |
Let me rephrase: With With the removal of Can you think of a use case for |
|
Thanks for elaborating @mxinden! Makes sense now.
I guess the only use case is if the wrapping
Yep :) |
Description
When generating the
OutEventfor aNetworkBehaviour, add thewhereclause of theNetworkBehaviourstructto the generatedenum.Links to any relevant issues
Follow up to #2792
Open Questions
Change checklist