fn pat_items_count<'a, I: 'a, U: 'a>(items: I) -> Result<(bool, usize), CompileError>
where
    I: IntoIterator<Item = &'a (ast::Pat, U)>,
    I::IntoIter: DoubleEndedIterator,
{
    let mut it = items.into_iter();

    let (is_open, mut count) = match it.next_back() {
        Some((pat, _)) => {
            if matches!(pat, ast::Pat::PatRest(..)) {
                (true, 0)
            } else {
                (false, 1)
            }
        }
        None => return Ok((false, 0)),
    };

    for (pat, _) in it {
        if let ast::Pat::PatRest(rest) = pat {
            return Err(CompileError::new(
                rest,
                CompileErrorKind::UnsupportedPatternRest,
            ));
        }

        count += 1;
    }

    Ok((is_open, count))
}
/// Test if the given pattern is open or not.
Test if the given pattern is open or not.
Test if the given pattern is open or not .
fn pat_items_count<'a, I: 'a, U: 'a>(items: I) -> Result<(bool, usize), CompileError>
where
    I: IntoIterator<Item = &'a (ast::Pat, U)>,
    I::IntoIter: DoubleEndedIterator,
{
    let mut it = items.into_iter();
    let (is_open, mut count) = match it.next_back() {
        Some((pat, _)) => {
            if matches!(pat, ast::Pat::PatRest(..)) {
                (true, 0)
            } else {
                (false, 1)
            }
        }
        None => return Ok((false, 0)),
    };
    for (pat, _) in it {
        if let ast::Pat::PatRest(rest) = pat {
            return Err(CompileError::new(
                rest,
                CompileErrorKind::UnsupportedPatternRest,
            ));
        }
        count += 1;
    }
    Ok((is_open, count))
}
fn pat_items_count < ' a , I : ' a , U : ' a > ( items : I ) -> Result < ( bool , usize ) , CompileError > where I : IntoIterator < Item = & ' a ( ast :: Pat , U ) > , I :: IntoIter : DoubleEndedIterator , { let mut it = items . into_iter ( ) ; let ( is_open , mut count ) = match it . next_back ( ) { Some ( ( pat , _ ) ) => { if matches ! ( pat ast Pat PatRest ( ) ) { ( true , 0 ) } else { ( false , 1 ) } } None => return Ok ( ( false , 0 ) ) , } ; for ( pat , _ ) in it { if let ast :: Pat :: PatRest ( rest ) = pat { return Err ( CompileError :: new ( rest , CompileErrorKind :: UnsupportedPatternRest , ) ) ; } count += 1 ; } Ok ( ( is_open , count ) ) }
Test if the given pattern is open or not.
Test if the given pattern is open or not .
items
I
items
I