It is a cool trick. By giving this size hint, it gives ts and us the chance to reserve the space for the extend calls in the loop. According to the documentation

size_hint() is primarily intended to be used for optimizations such as reserving space for the elements of the iterator, but must not be trusted to e.g. omit bounds checks in unsafe code. An incorrect implementation of size_hint() should not lead to memory safety violations.

Note that the creation of SizeHint is necessary because the extend call in for loop is made with a Some value ( Optional implements the Iterator trait), and the size_hint for a Some value is (1, Some(1)) . That doesn't help with pre allocation.

But looking at the code for Vec , this will have no effect (neither in HashMap and VecDeque ). Others Extend implementations may be different.

The execution of ts.extend(SizeHint(lo, hi, marker::PhantomData)); does not trigger a resize , since next returns None . Maybe some one should write a patch.