Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

impl TrustedLen is unsafe #1318

Merged
merged 2 commits into from
Jun 12, 2023
Merged

impl TrustedLen is unsafe #1318

merged 2 commits into from
Jun 12, 2023

Conversation

dhardy
Copy link
Member

@dhardy dhardy commented Jun 9, 2023

Implementing TrustedLen is now unsafe.

From what I understand, quite a few people are still unhappy about the design since the unsafe marker in this case is a promise that size_hint() in a different impl is accurate, so this may change again.

Anyway, we need to do something to fix our builds, and the alternative is just to remove this (I haven't a clue if it is enabling any important optimisations).

Implementing `TrustedLen` is now unsafe.

From what I understand, quite a few people are still unhappy about the design since the `unsafe` marker in this case is a promise that `size_hint()` in a *different* impl is accurate, so this may change again.

Anyway, we need to do something to fix our builds, and the alternative is just to remove this (I haven't a clue if it is enabling any important optimisations).
@newpavlov
Copy link
Member

I think we can simply remove it. While TrustedLen impl should allow a sligthly better codegen when DistIter is used with TrustedLen-aware combinators (e.g. Take), arguably, it's not worth the trouble and additional unsafe.

@dhardy
Copy link
Member Author

dhardy commented Jun 9, 2023

Sure, one less problem to have.

@dhardy dhardy merged commit 0c4c6c0 into master Jun 12, 2023
@vks vks deleted the unsafe-trusted-len branch June 15, 2023 07:53
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants