@ -236,6 +236,16 @@ pub trait IntoContextIter {{
fn into_context_iter ( self ) -> Self ::IntoIter ;
fn into_context_iter ( self ) -> Self ::IntoIter ;
} }
} }
pub trait Length { {
fn len ( & self ) -> usize ;
} }
impl < T > Length for std ::vec ::Vec < T > { {
fn len ( & self ) -> usize { {
std ::vec ::Vec ::len ( self )
} }
} }
pub struct ContextIterWrapper < I , C > { {
pub struct ContextIterWrapper < I , C > { {
iter : I ,
iter : I ,
_ctx : std ::marker ::PhantomData < C > ,
_ctx : std ::marker ::PhantomData < C > ,
@ -289,6 +299,11 @@ impl<T, E: Extend<T>, C> Extend<T> for ContextIterWrapper<E, C> {{
fn extend < I : IntoIterator < Item = T > > ( & mut self , iter : I ) { {
fn extend < I : IntoIterator < Item = T > > ( & mut self , iter : I ) { {
self . iter . extend ( iter ) ;
self . iter . extend ( iter ) ;
} }
} }
} }
impl < L : Length , C > Length for ContextIterWrapper < L , C > { {
fn len ( & self ) -> usize { {
self . iter . len ( )
} }
} }
} }
" # ,
" # ,
)
)
@ -406,7 +421,7 @@ impl<T, E: Extend<T>, C> Extend<T> for ContextIterWrapper<E, C> {{
if let ReturnKind ::Iterator = sig . ret_kind {
if let ReturnKind ::Iterator = sig . ret_kind {
writeln ! (
writeln ! (
ctx . out ,
ctx . out ,
"{} returns: &mut impl Extend<{}>," ,
"{} returns: &mut ( impl Extend<{}> + Length) ," ,
& ctx . indent , ret
& ctx . indent , ret
) ? ;
) ? ;
}
}
@ -635,7 +650,14 @@ impl<T, E: Extend<T>, C> Extend<T> for ContextIterWrapper<E, C> {{
match ret_kind {
match ret_kind {
ReturnKind ::Plain = > writeln ! ( ctx . out , ";" ) ? ,
ReturnKind ::Plain = > writeln ! ( ctx . out , ";" ) ? ,
ReturnKind ::Option = > writeln ! ( ctx . out , ");" ) ? ,
ReturnKind ::Option = > writeln ! ( ctx . out , ");" ) ? ,
ReturnKind ::Iterator = > writeln ! ( ctx . out , "));" ) ? ,
ReturnKind ::Iterator = > {
writeln ! ( ctx . out , "));" ) ? ;
writeln ! (
ctx . out ,
"{}if returns.len() >= MAX_ISLE_RETURNS {{ return; }}" ,
ctx . indent
) ? ;
}
}
}
}
}
}
}