Add a safety warning in ExactSizeIterator
documentation
#81739
Labels
A-docs
Area: Documentation for any part of the project, including the compiler, standard library, and tools
A-iterators
Area: Iterators
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
ExactSizeIterator
is a safe trait. Thus, unsafe code cannot rely on the correctness ofsize_hint()
when it is related to the program safety. However, this trait seems to be used in the wild in such context, for example:https://github.com/tiby312/reorder/blob/59ad9be6989de8eee948510b850851105ecad22e/src/lib.rs#L44-L57
I believe adding a warning about such misunderstanding like what is written in the
read()
document help prevent the future soundness bugs.The text was updated successfully, but these errors were encountered: