Trait AsLegacyRange
pub(in ::iter::adapters::step_by) trait AsLegacyRange<T>
For these implementations, SpecRangeSetup calculates the number
of iterations that will be needed and stores that in iter.end.
The various iterator implementations then rely on that to not need overflow checking, letting loops just be counted instead.
These only work for unsigned types, and will need to be reworked if you want to use it to specialize on signed types.
Currently these are only implemented for integers up to usize due to
correctness issues around ExactSizeIterator impls on 16bit platforms.
And since ExactSizeIterator is a prerequisite for backwards iteration
and we must consistently specialize backwards and forwards iteration
that makes the situation complicated enough that it's not covered
for now.
After SpecRangeSetup::setup, both Range<T> and its new-range wrapper
RangeIter<T> carry the cursor and countdown in the same underlying legacy
Range. This accessor exposes that shared range so one specialization can
serve both: it is an identity for Range<T> and unwraps the newtype for
RangeIter<T>, so it compiles away.
Required Methods
fn as_legacy_range(&self) -> &Range<T>fn as_legacy_range_mut(&mut self) -> &mut Range<T>
Implementors
impl<T> AsLegacyRange<T> for Range<T>impl<T> AsLegacyRange<T> for RangeIter<T>