From 9f4360cc82b999667fad743ec022e4351ce53beb Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Wed, 26 Jul 2023 17:39:57 +0000 Subject: [PATCH] refactor: drop array iteration inlining --- --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ package.repository = "https://github.com/CertainLach/jrsonnet" members = ["crates/*", "bindings/jsonnet", "cmds/jrsonnet", "tests"] default-members = ["cmds/jrsonnet"] +resolver = "2" [workspace.dependencies] jrsonnet-evaluator = { path = "./crates/jrsonnet-evaluator", version = "0.5.0-pre9" } --- a/crates/jrsonnet-evaluator/src/arr/mod.rs +++ b/crates/jrsonnet-evaluator/src/arr/mod.rs @@ -185,36 +185,15 @@ pass!(self.get_lazy(index)) } - #[cfg(feature = "nightly")] - pub fn iter(&self) -> UnknownArrayIter<'_> { - pass_iter_call!(self.iter => UnknownArrayIter) - } - #[cfg(not(feature = "nightly"))] pub fn iter(&self) -> impl ArrayLikeIter> + '_ { (0..self.len()).map(|i| self.get(i).transpose().expect("length checked")) } /// Iterate over elements, returning lazy values. - #[cfg(feature = "nightly")] - pub fn iter_lazy(&self) -> UnknownArrayIterLazy<'_> { - pass_iter_call!(self.iter_lazy => UnknownArrayIterLazy) - } - #[cfg(not(feature = "nightly"))] pub fn iter_lazy(&self) -> impl ArrayLikeIter> + '_ { (0..self.len()).map(|i| self.get_lazy(i).expect("length checked")) } - #[cfg(feature = "nightly")] - pub fn iter_cheap(&self) -> Option> { - macro_rules! question { - ($v:expr) => { - $v? - }; - } - Some(pass_iter_call!(self.iter_cheap in question => UnknownArrayIterCheap)) - } - - #[cfg(not(feature = "nightly"))] pub fn iter_cheap(&self) -> Option + '_> { if self.is_cheap() { Some((0..self.len()).map(|i| self.get_cheap(i).expect("length and is_cheap checked"))) --- a/crates/jrsonnet-evaluator/src/arr/spec.rs +++ b/crates/jrsonnet-evaluator/src/arr/spec.rs @@ -1,6 +1,3 @@ -//! Those implementations are a bit sketchy, as this is mostly performance experiments -//! of not yet finished nightly rust features - use std::{cell::RefCell, iter, mem::replace, rc::Rc}; use jrsonnet_gcmodule::{Cc, Trace}; @@ -17,19 +14,6 @@ }; pub trait ArrayLike: Sized + Into { - #[cfg(feature = "nightly")] - type Iter<'t> - where - Self: 't; - #[cfg(feature = "nightly")] - type IterLazy<'t> - where - Self: 't; - #[cfg(feature = "nightly")] - type IterCheap<'t> - where - Self: 't; - fn len(&self) -> usize; fn is_empty(&self) -> bool { self.len() == 0 @@ -37,13 +21,6 @@ fn get(&self, index: usize) -> Result>; fn get_lazy(&self, index: usize) -> Option>; fn get_cheap(&self, index: usize) -> Option; - #[cfg(feature = "nightly")] - #[allow(clippy::iter_not_returning_iterator)] - fn iter(&self) -> Self::Iter<'_>; - #[cfg(feature = "nightly")] - fn iter_lazy(&self) -> Self::IterLazy<'_>; - #[cfg(feature = "nightly")] - fn iter_cheap(&self) -> Option>; fn reverse(self) -> ArrValue { ArrValue::Reverse(Cc::new(ReverseArray(self.into()))) @@ -59,7 +36,6 @@ } impl SliceArray { - #[cfg(not(feature = "nightly"))] fn iter(&self) -> impl Iterator> + '_ { self.inner .iter() @@ -68,7 +44,6 @@ .step_by(self.step as usize) } - #[cfg(not(feature = "nightly"))] fn iter_lazy(&self) -> impl Iterator> + '_ { self.inner .iter_lazy() @@ -77,7 +52,6 @@ .step_by(self.step as usize) } - #[cfg(not(feature = "nightly"))] fn iter_cheap(&self) -> Option + '_> { Some( self.inner @@ -88,20 +62,7 @@ ) } } -#[cfg(feature = "nightly")] -type SliceArrayIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type SliceArrayLazyIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type SliceArrayCheapIter<'t> = impl DoubleEndedIterator + ExactSizeIterator + 't; impl ArrayLike for SliceArray { - #[cfg(feature = "nightly")] - type Iter<'t> = SliceArrayIter<'t>; - #[cfg(feature = "nightly")] - type IterLazy<'t> = SliceArrayLazyIter<'t>; - #[cfg(feature = "nightly")] - type IterCheap<'t> = SliceArrayCheapIter<'t>; - fn len(&self) -> usize { iter::repeat(()) .take((self.to - self.from) as usize) @@ -120,35 +81,6 @@ fn get_cheap(&self, index: usize) -> Option { self.iter_cheap()?.nth(index) } - - #[cfg(feature = "nightly")] - fn iter(&self) -> SliceArrayIter<'_> { - self.inner - .iter() - .skip(self.from as usize) - .take((self.to - self.from) as usize) - .step_by(self.step as usize) - } - - #[cfg(feature = "nightly")] - fn iter_lazy(&self) -> SliceArrayLazyIter<'_> { - self.inner - .iter_lazy() - .skip(self.from as usize) - .take((self.to - self.from) as usize) - .step_by(self.step as usize) - } - - #[cfg(feature = "nightly")] - fn iter_cheap(&self) -> Option> { - Some( - self.inner - .iter_cheap()? - .skip(self.from as usize) - .take((self.to - self.from) as usize) - .step_by(self.step as usize), - ) - } } impl From for ArrValue { fn from(value: SliceArray) -> Self { @@ -158,20 +90,7 @@ #[derive(Trace, Debug, Clone)] pub struct CharArray(pub Rc>); -#[cfg(feature = "nightly")] -type CharArrayIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type CharArrayLazyIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type CharArrayCheapIter<'t> = impl DoubleEndedIterator + ExactSizeIterator + 't; impl ArrayLike for CharArray { - #[cfg(feature = "nightly")] - type Iter<'t> = CharArrayIter<'t>; - #[cfg(feature = "nightly")] - type IterLazy<'t> = CharArrayLazyIter<'t>; - #[cfg(feature = "nightly")] - type IterCheap<'t> = CharArrayCheapIter<'t>; - fn len(&self) -> usize { self.0.len() } @@ -188,30 +107,7 @@ self.0 .get(index) .map(|v| Val::Str(StrValue::Flat(IStr::from(*v)))) - } - - #[cfg(feature = "nightly")] - fn iter(&self) -> CharArrayIter<'_> { - self.0 - .iter() - .map(|v| Ok(Val::Str(StrValue::Flat(IStr::from(*v))))) } - - #[cfg(feature = "nightly")] - fn iter_lazy(&self) -> CharArrayLazyIter<'_> { - self.0 - .iter() - .map(|v| Thunk::evaluated(Val::Str(StrValue::Flat(IStr::from(*v))))) - } - - #[cfg(feature = "nightly")] - fn iter_cheap(&self) -> Option> { - Some( - self.0 - .iter() - .map(|v| Val::Str(StrValue::Flat(IStr::from(*v)))), - ) - } } impl From for ArrValue { fn from(value: CharArray) -> Self { @@ -221,20 +117,7 @@ #[derive(Trace, Debug, Clone)] pub struct BytesArray(pub IBytes); -#[cfg(feature = "nightly")] -type BytesArrayIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type BytesArrayLazyIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type BytesArrayCheapIter<'t> = impl DoubleEndedIterator + ExactSizeIterator + 't; impl ArrayLike for BytesArray { - #[cfg(feature = "nightly")] - type Iter<'t> = BytesArrayIter<'t>; - #[cfg(feature = "nightly")] - type IterLazy<'t> = BytesArrayLazyIter<'t>; - #[cfg(feature = "nightly")] - type IterCheap<'t> = BytesArrayCheapIter<'t>; - fn len(&self) -> usize { self.0.len() } @@ -250,23 +133,6 @@ fn get_cheap(&self, index: usize) -> Option { self.0.get(index).map(|v| Val::Num(f64::from(*v))) } - - #[cfg(feature = "nightly")] - fn iter(&self) -> BytesArrayIter<'_> { - self.0.iter().map(|v| Ok(Val::Num(f64::from(*v)))) - } - - #[cfg(feature = "nightly")] - fn iter_lazy(&self) -> BytesArrayLazyIter<'_> { - self.0 - .iter() - .map(|v| Thunk::evaluated(Val::Num(f64::from(*v)))) - } - - #[cfg(feature = "nightly")] - fn iter_cheap(&self) -> Option> { - Some(self.0.iter().map(|v| Val::Num(f64::from(*v)))) - } } impl From for ArrValue { fn from(value: BytesArray) -> Self { @@ -297,20 +163,7 @@ })) } } -#[cfg(feature = "nightly")] -type ExprArrayIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type ExprArrayLazyIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type ExprArrayCheapIter<'t> = iter::Empty; impl ArrayLike for ExprArray { - #[cfg(feature = "nightly")] - type Iter<'t> = ExprArrayIter<'t>; - #[cfg(feature = "nightly")] - type IterLazy<'t> = ExprArrayLazyIter<'t>; - #[cfg(feature = "nightly")] - type IterCheap<'t> = ExprArrayCheapIter<'t>; - fn len(&self) -> usize { self.0.cached.borrow().len() } @@ -374,19 +227,6 @@ fn get_cheap(&self, _index: usize) -> Option { None } - - #[cfg(feature = "nightly")] - fn iter(&self) -> ExprArrayIter<'_> { - (0..self.len()).map(|i| self.get(i).transpose().expect("index checked")) - } - #[cfg(feature = "nightly")] - fn iter_lazy(&self) -> ExprArrayLazyIter<'_> { - (0..self.len()).map(|i| self.get_lazy(i).expect("index checked")) - } - #[cfg(feature = "nightly")] - fn iter_cheap(&self) -> Option> { - None - } } impl From for ArrValue { fn from(value: ExprArray) -> Self { @@ -401,14 +241,6 @@ split: usize, len: usize, } -#[cfg(feature = "nightly")] - -type ExtendedArrayIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type ExtendedArrayLazyIter<'t> = - impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type ExtendedArrayCheapIter<'t> = impl DoubleEndedIterator + ExactSizeIterator + 't; impl ExtendedArray { pub fn new(a: ArrValue, b: ArrValue) -> Self { let a_len = a.len(); @@ -459,13 +291,6 @@ } } impl ArrayLike for ExtendedArray { - #[cfg(feature = "nightly")] - type Iter<'t> = ExtendedArrayIter<'t>; - #[cfg(feature = "nightly")] - type IterLazy<'t> = ExtendedArrayLazyIter<'t>; - #[cfg(feature = "nightly")] - type IterCheap<'t> = ExtendedArrayCheapIter<'t>; - fn get(&self, index: usize) -> Result> { if self.split > index { self.a.get(index) @@ -492,21 +317,6 @@ self.b.get_cheap(index - self.split) } } - - #[cfg(feature = "nightly")] - fn iter(&self) -> ExtendedArrayIter<'_> { - WithExactSize(self.a.iter().chain(self.b.iter()), self.len) - } - #[cfg(feature = "nightly")] - fn iter_lazy(&self) -> ExtendedArrayLazyIter<'_> { - WithExactSize(self.a.iter_lazy().chain(self.b.iter_lazy()), self.len) - } - #[cfg(feature = "nightly")] - fn iter_cheap(&self) -> Option> { - let a = self.a.iter_cheap()?; - let b = self.b.iter_cheap()?; - Some(WithExactSize(a.chain(b), self.len)) - } } impl From for ArrValue { fn from(value: ExtendedArray) -> Self { @@ -516,22 +326,7 @@ #[derive(Trace, Debug, Clone)] pub struct LazyArray(pub Cc>>); -#[cfg(feature = "nightly")] -type LazyArrayIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type LazyArrayLazyIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type LazyArrayCheapIter<'t> = iter::Empty; impl ArrayLike for LazyArray { - #[cfg(feature = "nightly")] - type Iter<'t> = LazyArrayIter<'t>; - - #[cfg(feature = "nightly")] - type IterLazy<'t> = LazyArrayLazyIter<'t>; - - #[cfg(feature = "nightly")] - type IterCheap<'t> = LazyArrayCheapIter<'t>; - fn len(&self) -> usize { self.0.len() } @@ -547,18 +342,6 @@ fn get_lazy(&self, index: usize) -> Option> { self.0.get(index).cloned() } - #[cfg(feature = "nightly")] - fn iter(&self) -> LazyArrayIter<'_> { - self.0.iter().map(Thunk::evaluate) - } - #[cfg(feature = "nightly")] - fn iter_lazy(&self) -> LazyArrayLazyIter<'_> { - self.0.iter().cloned() - } - #[cfg(feature = "nightly")] - fn iter_cheap(&self) -> Option> { - None - } } impl From for ArrValue { fn from(value: LazyArray) -> Self { @@ -568,22 +351,7 @@ #[derive(Trace, Debug, Clone)] pub struct EagerArray(pub Cc>); -#[cfg(feature = "nightly")] -type EagerArrayIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type EagerArrayLazyIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type EagerArrayCheapIter<'t> = impl DoubleEndedIterator + ExactSizeIterator + 't; impl ArrayLike for EagerArray { - #[cfg(feature = "nightly")] - type Iter<'t> = EagerArrayIter<'t>; - - #[cfg(feature = "nightly")] - type IterLazy<'t> = EagerArrayLazyIter<'t>; - - #[cfg(feature = "nightly")] - type IterCheap<'t> = EagerArrayCheapIter<'t>; - fn len(&self) -> usize { self.0.len() } @@ -599,21 +367,6 @@ fn get_cheap(&self, index: usize) -> Option { self.0.get(index).cloned() } - - #[cfg(feature = "nightly")] - fn iter(&self) -> EagerArrayIter<'_> { - self.0.iter().cloned().map(Ok) - } - - #[cfg(feature = "nightly")] - fn iter_lazy(&self) -> EagerArrayLazyIter<'_> { - self.0.iter().cloned().map(Thunk::evaluated) - } - - #[cfg(feature = "nightly")] - fn iter_cheap(&self) -> Option> { - Some(self.0.iter().cloned()) - } } impl From for ArrValue { fn from(value: EagerArray) -> Self { @@ -648,22 +401,7 @@ } } -#[cfg(feature = "nightly")] -type RangeArrayIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type RangeArrayLazyIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type RangeArrayCheapIter<'t> = impl DoubleEndedIterator + ExactSizeIterator + 't; impl ArrayLike for RangeArray { - #[cfg(feature = "nightly")] - type Iter<'t> = RangeArrayIter<'t>; - - #[cfg(feature = "nightly")] - type IterLazy<'t> = RangeArrayLazyIter<'t>; - - #[cfg(feature = "nightly")] - type IterCheap<'t> = RangeArrayCheapIter<'t>; - fn len(&self) -> usize { self.range().len() } @@ -682,22 +420,6 @@ fn get_cheap(&self, index: usize) -> Option { self.range().nth(index).map(|i| Val::Num(f64::from(i))) } - - #[cfg(feature = "nightly")] - fn iter(&self) -> RangeArrayIter<'_> { - self.range().map(|i| Ok(Val::Num(f64::from(i)))) - } - - #[cfg(feature = "nightly")] - fn iter_lazy(&self) -> RangeArrayLazyIter<'_> { - self.range() - .map(|i| Thunk::evaluated(Val::Num(f64::from(i)))) - } - - #[cfg(feature = "nightly")] - fn iter_cheap(&self) -> Option> { - Some(self.range().map(|i| Val::Num(f64::from(i)))) - } } impl From for ArrValue { fn from(value: RangeArray) -> Self { @@ -708,15 +430,6 @@ #[derive(Debug, Trace, Clone)] pub struct ReverseArray(pub ArrValue); impl ArrayLike for ReverseArray { - #[cfg(feature = "nightly")] - type Iter<'t> = iter::Rev>; - - #[cfg(feature = "nightly")] - type IterLazy<'t> = iter::Rev>; - - #[cfg(feature = "nightly")] - type IterCheap<'t> = iter::Rev>; - fn len(&self) -> usize { self.0.len() } @@ -732,21 +445,6 @@ fn get_cheap(&self, index: usize) -> Option { self.0.get_cheap(self.0.len() - index - 1) } - - #[cfg(feature = "nightly")] - fn iter(&self) -> iter::Rev> { - self.0.iter().rev() - } - - #[cfg(feature = "nightly")] - fn iter_lazy(&self) -> iter::Rev> { - self.0.iter_lazy().rev() - } - - #[cfg(feature = "nightly")] - fn iter_cheap(&self) -> Option>> { - Some(self.0.iter_cheap()?.rev()) - } fn reverse(self) -> ArrValue { self.0 } @@ -775,20 +473,7 @@ })) } } -#[cfg(feature = "nightly")] -type MappedArrayIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type MappedArrayLazyIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type MappedArrayCheapIter<'t> = iter::Empty; impl ArrayLike for MappedArray { - #[cfg(feature = "nightly")] - type Iter<'t> = MappedArrayIter<'t>; - #[cfg(feature = "nightly")] - type IterLazy<'t> = MappedArrayLazyIter<'t>; - #[cfg(feature = "nightly")] - type IterCheap<'t> = MappedArrayCheapIter<'t>; - fn len(&self) -> usize { self.0.cached.borrow().len() } @@ -860,21 +545,6 @@ } fn get_cheap(&self, _index: usize) -> Option { - None - } - - #[cfg(feature = "nightly")] - fn iter(&self) -> MappedArrayIter<'_> { - (0..self.len()).map(|i| self.get(i).transpose().expect("length checked")) - } - - #[cfg(feature = "nightly")] - fn iter_lazy(&self) -> MappedArrayLazyIter<'_> { - (0..self.len()).map(|i| self.get_lazy(i).expect("length checked")) - } - - #[cfg(feature = "nightly")] - fn iter_cheap(&self) -> Option> { None } } @@ -906,21 +576,7 @@ } } -#[cfg(feature = "nightly")] -type RepeatedArrayIter<'t> = impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type RepeatedArrayLazyIter<'t> = - impl DoubleEndedIterator> + ExactSizeIterator + 't; -#[cfg(feature = "nightly")] -type RepeatedArrayCheapIter<'t> = impl DoubleEndedIterator + ExactSizeIterator + 't; impl ArrayLike for RepeatedArray { - #[cfg(feature = "nightly")] - type Iter<'t> = RepeatedArrayIter<'t>; - #[cfg(feature = "nightly")] - type IterLazy<'t> = RepeatedArrayLazyIter<'t>; - #[cfg(feature = "nightly")] - type IterCheap<'t> = RepeatedArrayCheapIter<'t>; - fn len(&self) -> usize { self.0.total_len } @@ -945,56 +601,11 @@ } self.0.data.get_cheap(index % self.0.data.len()) } - - #[cfg(feature = "nightly")] - fn iter(&self) -> RepeatedArrayIter<'_> { - (0..self.0.total_len) - .map(|i| self.get(i)) - .map(Result::transpose) - .map(Option::unwrap) - } - - #[cfg(feature = "nightly")] - fn iter_lazy(&self) -> RepeatedArrayLazyIter<'_> { - (0..self.0.total_len) - .map(|i| self.get_lazy(i)) - .map(Option::unwrap) - } - - #[cfg(feature = "nightly")] - fn iter_cheap(&self) -> Option> { - if !self.0.data.is_cheap() { - return None; - } - Some( - (0..self.0.total_len) - .map(|i| self.get_cheap(i)) - .map(Option::unwrap), - ) - } } impl From for ArrValue { fn from(value: RepeatedArray) -> Self { Self::Repeated(value) } -} - -#[cfg(feature = "nightly")] -macro_rules! impl_iter_enum { - ($n:ident => $v:ident) => { - pub enum $n<'t> { - Bytes(::$v<'t>), - Expr(::$v<'t>), - Lazy(::$v<'t>), - Eager(::$v<'t>), - Range(::$v<'t>), - Slice(Box<::$v<'t>>), - Extended(Box<::$v<'t>>), - Reverse(Box<::$v<'t>>), - Mapped(Box<::$v<'t>>), - Repeated(Box<::$v<'t>>), - } - }; } macro_rules! pass { @@ -1015,81 +626,3 @@ }; } pub(super) use pass; - -#[cfg(feature = "nightly")] -macro_rules! pass_iter_call { - ($t:ident.$c:ident $(in $wrap:ident)? => $e:ident) => { - match $t { - ArrValue::Bytes(e) => $e::Bytes($($wrap!)?(e.$c())), - ArrValue::Lazy(e) => $e::Lazy($($wrap!)?(e.$c())), - ArrValue::Expr(e) => $e::Expr($($wrap!)?(e.$c())), - ArrValue::Eager(e) => $e::Eager($($wrap!)?(e.$c())), - ArrValue::Range(e) => $e::Range($($wrap!)?(e.$c())), - ArrValue::Slice(e) => $e::Slice(Box::new($($wrap!)?(e.$c()))), - ArrValue::Extended(e) => $e::Extended(Box::new($($wrap!)?(e.$c()))), - ArrValue::Reverse(e) => $e::Reverse(Box::new($($wrap!)?(e.$c()))), - ArrValue::Mapped(e) => $e::Mapped(Box::new($($wrap!)?(e.$c()))), - ArrValue::Repeated(e) => $e::Repeated(Box::new($($wrap!)?(e.$c()))), - } - }; -} -#[cfg(feature = "nightly")] -pub(super) use pass_iter_call; - -#[cfg(feature = "nightly")] -macro_rules! impl_iter { - ($t:ident => $out:ty) => { - impl Iterator for $t<'_> { - type Item = $out; - - fn next(&mut self) -> Option { - pass!(self.next()) - } - fn nth(&mut self, count: usize) -> Option { - pass!(self.nth(count)) - } - fn size_hint(&self) -> (usize, Option) { - pass!(self.size_hint()) - } - } - impl DoubleEndedIterator for $t<'_> { - fn next_back(&mut self) -> Option { - pass!(self.next_back()) - } - fn nth_back(&mut self, count: usize) -> Option { - pass!(self.nth_back(count)) - } - } - impl ExactSizeIterator for $t<'_> { - fn len(&self) -> usize { - match self { - Self::Bytes(e) => e.len(), - Self::Expr(e) => e.len(), - Self::Lazy(e) => e.len(), - Self::Eager(e) => e.len(), - Self::Range(e) => e.len(), - Self::Slice(e) => e.len(), - Self::Extended(e) => { - e.size_hint().1.expect("overflow is checked in constructor") - } - Self::Reverse(e) => e.len(), - Self::Mapped(e) => e.len(), - Self::Repeated(e) => e.len(), - } - } - } - }; -} - -#[cfg(feature = "nightly")] -impl_iter_enum!(UnknownArrayIter => Iter); -#[cfg(feature = "nightly")] -impl_iter!(UnknownArrayIter => Result); -#[cfg(feature = "nightly")] -impl_iter_enum!(UnknownArrayIterLazy => IterLazy); -#[cfg(feature = "nightly")] -impl_iter!(UnknownArrayIterLazy => Thunk); -#[cfg(feature = "nightly")] -impl_iter_enum!(UnknownArrayIterCheap => IterCheap); -#[cfg(feature = "nightly")] -impl_iter!(UnknownArrayIterCheap => Val); -- gitstuff