We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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.
zebra_network
select
Either
Either<Either<_, _>, _>
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:
peer::connection::Connection::run
Either<PeerMessage, Either<ResponseTimeout, CancelChannel>>
PeerMessage
ResponseTimeout
CancelChannel
connection.rs
fail_with
In peer_set::initialize::initialize:
peer_set::initialize::initialize
map Either<Either<DemandSignal, CrawlTimer>, Handshake> to a custom enum with DemandSignal, CrawlTimer, and Handshake variants
Either<Either<DemandSignal, CrawlTimer>, Handshake>
DemandSignal
CrawlTimer
Handshake
Search for any other uses of the select function or macro
Discard unused fields while mapping to the enum, to simplify the match code
Match on the new enums
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<_, _>, _>.
Either3
The text was updated successfully, but these errors were encountered:
This is a useful refactor, but it's not needed.
Sorry, something went wrong.
No branches or pull requests
Is your feature request related to a problem? Please describe.
In
zebra_network
, we use nestedselect
s, then match onEither
(or a nestedEither<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
:Either<PeerMessage, Either<ResponseTimeout, CancelChannel>>
to a custom enum withPeerMessage
,ResponseTimeout
, andCancelChannel
variantsconnection.rs
to makefail_with
errors impossible #1721 moves this code down a few linesIn
peer_set::initialize::initialize
:map
Either<Either<DemandSignal, CrawlTimer>, Handshake>
to a custom enum withDemandSignal
,CrawlTimer
, andHandshake
variantsSearch for any other uses of the select function or macro
Discard unused fields while mapping to the enum, to simplify the match code
Match on the new enums
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 thanEither<Either<_, _>, _>
.The text was updated successfully, but these errors were encountered: