Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer type parameters on NetworkBehaviourAction #3240

Closed
thomaseizinger opened this issue Dec 14, 2022 · 0 comments
Closed

Infer type parameters on NetworkBehaviourAction #3240

thomaseizinger opened this issue Dec 14, 2022 · 0 comments

Comments

@thomaseizinger
Copy link
Contributor

thomaseizinger commented Dec 14, 2022

Description

Currently, we expose multiple type parameters on NetworkBehaviourAction despite all of them being able to be inferred from the corresponding NetworkBehaviour type. However, we do also expose individual mapping functions for the in-event etc.

We could consolidate all those type parameters into one but that would require us to put a bound onto the struct definition. Trait bounds should ideally always only be applied to functionality (i.e. impl blocks). Applying them to struct or enum definition easily creeps through into layers where you don't actually want them.

My suggestion would be to remove all trait bounds from NetworkBehaviourAction and expose the types as they are. For the common case where the types are unmapped, we can expose a type alias that infers all of these types from a type that implements NetworkBehaviour.

Motivation

Current Implementation

Are you planning to do it yourself in a pull request?

Yes.

mergify bot pushed a commit that referenced this issue Dec 22, 2022
Previously, we applied a lifetime onto the entire `RecordStore` to workaround Rust not having GATs. With Rust 1.65.0 we now have GATs so we can remove this workaround.

Related #3240. Without this change, we would have to specify HRTB in various places.
@thomaseizinger thomaseizinger closed this as not planned Won't fix, can't repro, duplicate, stale Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant