-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Iterator::fuse
is not guaranteed to fuse a generic iterator.
#83969
Comments
Iterator::fuse
is not guaranteed to actually fuse the given iterator.Iterator::fuse
is not guaranteed to fuse a generic iterator.
Well, by implementing (As a side note, unsafe code should not blindly rely on safe code, especially traits implementation, precisely because it is impossible to automatically check that implementations are logically correct.) EDIT : maybe I misunderstood your request, are you suggesting |
Of course, the option of making the trait unsafe was discussed as part of the RFC, but it seems that the use case for the guarantees of That said, I do kind of see how somebody might look of the signature of pub fn fuse(self) -> Fuse<Self> and think, "ah, this returns a standard library type, so I should be able to trust this on an arbitrary iterator," without considering that |
I honestly imagine there is also a lot of unsafe code that relies on |
I feel that there is a difference, due to way that specialization impacts this. The danger of reliance on safe traits in unsafe code is so omnipresent that I would hope that most people who audit unsafe code already look for things like bad
On the other hand, if I were auditing unsafe code and saw a function take
|
I guess adding something along the line of
in the doc of |
Sounds good to me! |
playground
This means unsafe code may not rely on
iter.fuse()
to actually fuse the iterator ifiter
is generic, which is unexpected to me.I personally would like us to either add a note to
Iterator::fuse
mentioning this or to remove the specialization forstd::iter::Fused
.The text was updated successfully, but these errors were encountered: