/// Map a term to an association list.
///
/// See IEEE 1076-2008 section 6.5.7.
Map a term to an association list.
Map a term to an association list .
pub fn term_to_assoc_list(&self, term: Spanned<Term>) -> Result<Spanned<hir::AssocList>> {
        let term_span = term.span;
        Ok(Spanned::new(
            match term.value {
                Term::Paren(fields) => fields
                    .into_iter()
                    .map(|term| {
                        let actual = self.term_to_assoc_actual(term)?;
                        Ok(hir::AssocElement {
                            span: actual.span,
                            formal: None,
                            actual: actual,
                        })
                    })
                    .collect::<Vec<Result<_>>>()
                    .into_iter()
                    .collect::<Result<Vec<_>>>()?,
                Term::Aggregate(fields) => fields
                    .into_iter()
                    .map(|(formal, actual)| {
                        if formal.len() != 1 {
                            self.emit(
                                DiagBuilder2::error(
                                    "formal part of association element must be exactly one \
                                     expression",
                                )
                                .span(term_span),
                            );
                            return Err(());
                        }
                        let formal = formal.into_iter().next().unwrap();
                        let formal_span = formal.span;
                        let span = Span::union(formal.span, actual.span);
                        let formal = self.term_to_expr(formal)?;
                        let actual = self.term_to_assoc_actual(actual)?;
                        Ok(hir::AssocElement {
                            span: span,
                            formal: Some(Spanned::new(formal, formal_span)),
                            actual: actual,
                        })
                    })
                    .collect::<Vec<Result<_>>>()
                    .into_iter()
                    .collect::<Result<Vec<_>>>()?,
                _ => {
                    self.emit(
                        DiagBuilder2::error(format!(
                            "`{}` is not a valid association list",
                            term.span.extract()
                        ))
                        .span(term.span)
                        .add_note("See IEEE 1076-2008 section 6.5.7."),
                    );
                    debugln!("It is a {:#?}", term);
                    return Err(());
                }
            },
            term_span,
        ))
    }
pub fn term_to_assoc_list ( & self , term : Spanned < Term > ) -> Result < Spanned < hir :: AssocList > > { let term_span = term . span ; Ok ( Spanned :: new ( match term . value { Term :: Paren ( fields ) => fields . into_iter ( ) . map ( | term | { let actual = self . term_to_assoc_actual ( term ) ? ; Ok ( hir :: AssocElement { span : actual . span , formal : None , actual : actual , } ) } ) . collect :: < Vec < Result < _ > > > ( ) . into_iter ( ) . collect :: < Result < Vec < _ > > > ( ) ? , Term :: Aggregate ( fields ) => fields . into_iter ( ) . map ( | ( formal , actual ) | { if formal . len ( ) != 1 { self . emit ( DiagBuilder2 :: error ( " \
 " , ) . span ( term_span ) , ) ; return Err ( ( ) ) ; } let formal = formal . into_iter ( ) . next ( ) . unwrap ( ) ; let formal_span = formal . span ; let span = Span :: union ( formal . span , actual . span ) ; let formal = self . term_to_expr ( formal ) ? ; let actual = self . term_to_assoc_actual ( actual ) ? ; Ok ( hir :: AssocElement { span : span , formal : Some ( Spanned :: new ( formal , formal_span ) ) , actual : actual , } ) } ) . collect :: < Vec < Result < _ > > > ( ) . into_iter ( ) . collect :: < Result < Vec < _ > > > ( ) ? , _ => { self . emit ( DiagBuilder2 :: error ( format ! ( " " term span extract ( ) ) ) . span ( term . span ) . add_note ( " " ) , ) ; debugln ! ( " " term ) ; return Err ( ( ) ) ; } } , term_span , ) ) }
Map a term to an association list.
Map a term to an association list .
&self
term
Spanned<Term>