/// Map a term to an array constraint.
Map a term to an array constraint.
Map a term to an array constraint .
pub fn term_to_array_constraint(
        &self,
        span: Span,
        terms: Vec<Spanned<Term>>,
        elem: Option<Spanned<Term>>,
    ) -> Result<Spanned<hir::ArrayConstraint>> {
        if terms.is_empty() {
            self.emit(DiagBuilder2::error(format!("array constraint cannot be empty")).span(span));
            return Err(());
        }
        let indices = if terms.len() == 1 && terms[0].value == Term::Open {
            vec![]
        } else {
            terms
                .into_iter()
                .map(|e| self.term_to_discrete_range(e))
                .collect::<Result<Vec<_>>>()?
        };
        let elem = match elem {
            Some(e) => Some(self.term_to_element_constraint(e)?),
            None => None,
        };
        Ok(Spanned::new(
            hir::ArrayConstraint {
                span: span,
                index: indices,
                elem: elem.map(|e| Box::new(e)),
            },
            span,
        ))
    }
pub fn term_to_array_constraint ( & self , span : Span , terms : Vec < Spanned < Term > > , elem : Option < Spanned < Term > > , ) -> Result < Spanned < hir :: ArrayConstraint > > { if terms . is_empty ( ) { self . emit ( DiagBuilder2 :: error ( format ! ( " " ) ) . span ( span ) ) ; return Err ( ( ) ) ; } let indices = if terms . len ( ) == 1 && terms [ 0 ] . value == Term :: Open { vec ! [ ] } else { terms . into_iter ( ) . map ( | e | self . term_to_discrete_range ( e ) ) . collect :: < Result < Vec < _ > > > ( ) ? } ; let elem = match elem { Some ( e ) => Some ( self . term_to_element_constraint ( e ) ? ) , None => None , } ; Ok ( Spanned :: new ( hir :: ArrayConstraint { span : span , index : indices , elem : elem . map ( | e | Box :: new ( e ) ) , } , span , ) ) }
Map a term to an array constraint.
Map a term to an array constraint .
&self
span
Span
terms
Vec<Spanned<Term>>
elem
Option<Spanned<Term>>