-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
async_channel
: simplify logic to obtain Sender
/Receiver
endpoints
#776
async_channel
: simplify logic to obtain Sender
/Receiver
endpoints
#776
Conversation
No, not quite. Did you perhaps forget to commit some other changes from your local machine? The only change I currently see in this PR is a couple lines of doc comments on the The change we actually want to make is to ensure that the channel's sender and receiver counts are properly updated when obtaining a new instance of a sender or receiver. The best way to do this would be to re-use the code you recently added to the Let us know if you need more hints or would prefer that we take over the implementation task directly. |
0000991
to
644feca
Compare
Is it good now?
One of the reasons I'm contributing to this project is because I wanna gain experience and become a better Rust developer so I may one day hopefully get a Rust job. So hints would be preferable over the 2nd option. |
Functionally it appears correct! Nice work. Now, the next steps to improve things would be:
Of course, I surmised as much, that's why I'm happy to oblige you in the learning process. I appreciate your perseverance too! |
5a3940c
to
b419b13
Compare
good now? |
Did you have an issue with |
The logic from this commit was correct, we were just asking you to deduplicate the code logic now shared between One way you could do that is by extracting that logic into a separate function that is then called in both |
oh, that's what you meant by "deduplicate". I thought "deduplicate" meant "modify them so that they are different 😆 Ok I'll try a new iteration |
Ok, so I've been trying to deduplicate the They don't seem to be duplicate:
Are you sure that they are duplicate and need to be deduplicated? I'm not sure how to deduplicate it 🤔 |
b419b13
to
bf73d9a
Compare
The code in
Now, I could directly provide the implementation for this, but you have previously expressed the desire to learn, so I'll just provide one hint. Where should the new inner function go? Hint: what do the Also, please take a moment to study a git usage guide. There's no need for continuous force pushes, it makes it very hard to track the history of your changes since they keep getting removed and overwritten. Finally, before asking for another review pass, kindly take a moment to review your own code in the |
is macro expansion a feasible approach for deduplicating? I tried and it didn't work. I'm wondering whether I did it the wrong way or whether it's actually not possible. Here is my attempt:
I get this error:
|
here is the function I'm trying to create to combine
Here is another non-working attempt:
Any feedback? |
no need for anything nearly that complex. Hint: move the core functions into the |
bf73d9a
to
4269c04
Compare
I think I finally made it |
async_channel
: simplify logic to obtain Sender
/Receiver
endpoints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great now! Thanks, and glad we got there in the end. 👍
…ts (#776) * Each endpoint now offers a way to re-obtain the opposite endpoint, which can be used to help recover after a fault or another error caused the channel to be disconnected. * `Receiver::sender()` creates a new `Sender` connected to the same channel, which will re-mark the channel as connected if it was previously disconnected due to all `Senders` being dropped. * `Sender::receiver()` does the same thing, but for the opposite endpoint. * Deduplicate the logic shared between: * `Receiver::clone()` and `Sender::receiver()` * `Sender::clone()` and `Receiver::sender()` * Improve docs to clarify what can happen when obtaining new endpoints. Co-authored-by: Kevin Boos <[email protected]> 36b20bc
Addresses 2nd checkbox on #715. Is that checkbox complete now?
Continuation of #762