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.
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
[core] add
Exclusive
to sync #97629[core] add
Exclusive
to sync #97629Changes from all commits
63d1c86
029f9aa
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Is there a reason for the explicit
: Sized
bound?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.
just to make it clear how its different than the other impl block
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.
Could we have impls of
FnMut
andFnOnce
as well?Ditto for
Read
,Write
, and basically any stdlib trait with&mut self
methods exclusivelyThere 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.
Note that
Read::is_read_vectored
andWrite::is_write_vectored
take&self
, so those would both have to remain their defaultfalse
rather than forwarding inward.We could generalize that principle to implement traits where all required methods are owned or mutable, leaving any
&self
methods to their trait default. That could includeIterator
, for instance, implementingnext
but notsize_hint
. I'm not sure how far we should go with that, given that you can useget_mut
orinto_inner
for direct access anyway.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.
True, we could for starters limit ourselves to
Fn{Mut,Once}
, then, before considering the others which can always have a manual impl through a wrapper struct: not only are these the only traits stable users can't implement themselves, it's also sufficiently simple traits for them being implemented to be non-controversial.And even beyond manual impls on wrapper structs, we can also use ad-hoc closures and
from_fn
-like constructors (currently only forIterator
):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.
hmm, its a bit weird to me to only be able to forward some methods. The guidance we decide on would be: "if all the required methods only require
&mut
, then its okay to implement", as @cuviper mentioned, but i am tempted to only implement the ones that offer full functionality (Future
,FnOnce
,FnMut
), or none of themThere 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 agree that
FnOnce
andFnMut
are compelling for their simplicity and that they are unstable for users. It also relates to this forum thread, although I think they probably don't need the direct trait, per se.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.
Aren't impl's like these easy to add instantly-stable in the future?