-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Tracking issue for missing Iterator::size_hint implementations #49205
Copy link
Copy link
Closed
Labels
A-iteratorsArea: IteratorsArea: IteratorsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-iteratorsArea: IteratorsArea: IteratorsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
size_hint()can sometimes allow for more efficient memory allocations, and other good performance things.I intend to make a PR to implement the trivial / easy ones, at least. I've already made a PR for the first batch, #49201. The ones in that PR are omitted from this list.
This list will be updated as I sort through for false-positives.
Liballoc:
Range<'a, K, V>(Add size_hints for btree iterators #49550)This is hard, but doable, and useful.RangeMut<'a, K, V>(Add size_hints for btree iterators #49550)This is hard, but doable, and useful.MergeIter<K, V, I>(Add size_hints for btree iterators #49550)This is hard, but doable, and useful.Range<'a, T>(Add size_hints for btree iterators #49550)This is hard, but doable, and useful.Libcore:
Impossible to provide upper or lower bounds.Pattern: $forward_iterator<'a, P>Impossible to provide upper or lower bounds.Pattern: $reverse_iterator<'a, P>Libfmt_macros:
Both impossible and irrelevant.Parser<'a>Libproc_macro:
Implementation is not trivial. It would be nice to do it eventually, though.TokenTreeIterLibrustc:
NodesMatchingSuffix<'o, 'tcx>EnumerateAndAdjust<I>(Implement some trivial size_hints for various iterators #49201)TraitObligationStackList<'o, 'tcx>Not trivial, and probably going to change.AncestorsNo way to define an upper bound.Elaborator<'cx, 'gcx, 'tcx>No way to define an upper bound.SupertraitDefIds<'cx, 'gcx, 'tcx>No way to define an upper bound.TypeWalker<'tcx>Iter<'dom, Node>Iter<'a, T>Iter<'a>Prefixes<'cx, 'gcx, 'tcx>ValueIterAutoderef<'a, 'gcx, 'tcx>Librustdoc:
CodeBlocks<'a, I>LinkReplacer<'a, 'b, I>HeadingLinks<'a, 'b, I>SummaryLine<'a, I>Footnotes<'a, I>Parser<T>Libstd:
ReadDir(Implement size_hint on various sys iterators #49552)(implement size_hint on sys iterators #71308)There's no way to do this.Bytes<R>There's no way to do this.Chars<R>There's no way to do this.Split<B>Depreciated.Lines<B>There's no way to provide anything better thanIncoming<'a>(1, None)Iter<'a>(Implement size_hint on various sys iterators #49552)Writing aComponents<'a>size_hintfor this is hard. But it would be useful; this is oftencollect()-ed.Writing aAncestors<'a>size_hintfor this is hard, and not very useful.Inherently unbounded iterator.Iter<'a, T>Inherently unbounded iterator.TryIter<'a, T>Inherently unbounded iterator.IntoIter<T>Impossible to write an upper bound.PacketsReadDir(Implement size_hint on various sys iterators #49552)(implement size_hint on sys iterators #71308)LookupHost(Implement size_hint on various sys iterators #49552)(implement size_hint on sys iterators #71308)SplitPaths<'a>(Implement size_hint on various sys iterators #49552)(implement size_hint on sys iterators #71308)ReadDir(Implement size_hint on various sys iterators #49552)LookupHost(Implement size_hint on various sys iterators #49552)No cheap way to do this.ReadDirLookupHost(Implement size_hint on various sys iterators #49552)ReadDir(Implement size_hint on various sys iterators #49552)(implement size_hint on sys iterators #71308)LookupHost(Implement size_hint on various sys iterators #49552)(implement size_hint on sys iterators #71308)SplitPaths<'a>(Implement size_hint on various sys iterators #49552)(implement size_hint on sys iterators #71308)Env(Implement size_hint on various sys iterators #49552)(implement size_hint on sys iterators #71308)There's no cheap way to do this.ReadDirThere's no safe way to do this.EnvSplitPaths<'a>(Implement size_hint on various sys iterators #49552)(implement size_hint on sys iterators #71308)There's no safe way to do this.LookupHostToLowercase(Implement size_hint for several unicode-based iterators. #50208)ToUppercase(Implement size_hint for several unicode-based iterators. #50208)CaseMappingIter(Implement size_hint for several unicode-based iterators. #50208)Utf8LossyChunksIter<'a>(Implement size_hint for several unicode-based iterators. #50208)SplitWhitespace<'a>(Implement size_hint for several unicode-based iterators. #50208)Libsyntax:
FrameCursorCargo:
rust-lang/cargo#5211
I found them by running
grep -r -n "impl.*\bIterator for \|fn size_hint" src > size_hint_todo.txt. Then, delete any pairs of anIteratorline followed by asize_hintline, and manually check the remainingIteratorlines for false positives.It may be a good idea to make a lint for implementing size_hint. It would be opt-in, of course. It's really easy to forget, even if you're trying to optimize performance.