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

Map selects to a typed custom enum in zebra-network #1783

Closed
5 tasks
teor2345 opened this issue Feb 19, 2021 · 1 comment
Closed
5 tasks

Map selects to a typed custom enum in zebra-network #1783

teor2345 opened this issue Feb 19, 2021 · 1 comment
Labels
A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup

Comments

@teor2345
Copy link
Contributor

teor2345 commented Feb 19, 2021

Is your feature request related to a problem? Please describe.

In zebra_network, we use nested selects, then match on Either (or a nested Either<Either<_, _>, _>). This makes the code hard to read and maintain.

Describe the solution you'd like

Map Either to a custom typed enum, with variants named after the action taken for each of the selected futures.

In peer::connection::Connection::run:

In peer_set::initialize::initialize:

Describe alternatives you've considered

Do nothing: the code will continue to be hard to read and modify.

We could create a generic Either3, but that would only be slightly easier to read than Either<Either<_, _>, _>.

@teor2345 teor2345 added A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup S-needs-triage Status: A bug report needs triage P-Medium labels Feb 19, 2021
@mpguerra mpguerra added P-Low and removed P-Medium S-needs-triage Status: A bug report needs triage labels Feb 26, 2021
@teor2345 teor2345 changed the title Map nested selects to a custom enum in zebra-network Map selects to a typed custom enum in zebra-network Apr 9, 2021
@teor2345
Copy link
Contributor Author

This is a useful refactor, but it's not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup
Projects
None yet
Development

No branches or pull requests

2 participants