Skip to content

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants