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
sync::watch
: Add has_changed
flag and method to Ref
#4758
Merged
Darksonn
merged 5 commits into
tokio-rs:master
from
uklotzde:sync-watch-receiver-borrow_and_update_if_changed
Jun 29, 2022
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6445c44
sync::watch: Add Receiver::borrow_and_update_if_changed()
uklotzde 63c9987
sync::watch: Add an `updated` flag and method to `Ref`
uklotzde b4fef98
sync::watch::Ref: Replace updated() with has_changed()
uklotzde 67f94a7
Reword API docs
uklotzde f173977
Merge 'upstream/master' into 'uklotzde/sync-watch-receiver-borrow_and…
Darksonn File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
here's a minor API design suggestion. what if, instead of a tuple of
Ref
andbool
, we added the bool toref
along with aRef::changed()
method. that way, the meaning of the boolean value would be clearer at the callsite, as opposed to making the user responsible for naming the tuple field. it would also negate the need to have two separate methods.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.
That seems like a good way to go around it.
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.
Good point! I was already experimenting with such a design in my external wrapper crate. Just wanted to avoid introducing new, named types.
I didn't consider the fact that this solutions enables us to extend the current API without any breaking changes, which makes it even more appealing :) Thank you for the hint!
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.
I was blind 🙈 Your proposal turned out as the perfect solution that only affects
borrow_and_update()
when focusing on theupdated
aspect and not considering the more generalchanged
aspect: 63c9987There 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.
I noticed that commits will be squashed before merging, so I added the changes as a new commit.