Menu

Before adding another Iterator bound, check the compiler version
📰

Before adding another Iterator bound, check the compiler version

DEV Community: rust·Shivam Dwivedi·6 days ago
#Vn2qpYcO
#devtorust#devto#dev#iterator#cursor
Long article (780 words) — no AI summary yet.
Reading 0:00
15s threshold

The compiler says a type is not an iterator. The implementation already has a bound saying its dereference target is an iterator. Adding the same requirement again is a tempting way to make the error go away without understanding what changed.

Rust’s 1.100.1 release notes identify a regression in which valid iterator implementations were no longer recognized, following a change to the unstable const version of Iterator . [1] The linked report gives a particularly useful clue: the overridden nth and nth_back methods failed, while next and next_back were accepted. [2]

Unfold the type before changing the bound

The expression <Self as Deref>::Target means the associated target type supplied by this type’s Deref implementation. If Cursor<I> dereferences to I , that projection names I .

Original type-projection map. The version labels distinguish my local baseline from upstream report and release evidence. Image by Shivam Dwivedi.

Here is a small wrapper with a real stored iterator.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.