fn struct_parser(path: &Path, fields: &[Field<core::RcType>]) -> RcParseExpr {
    use var::ScopeIndex;

    let lower_to_field_parser = |field: &Field<core::RcType>| {
        (
            field.name.clone(),
            ty_parser(&path.append_child(field.name.0.clone()), &field.value),
        )
    };
    let lower_to_expr_field = |field: &Field<core::RcType>| Field {
        doc: Rc::clone(&field.doc),
        name: field.name.clone(),
        value: Expr::Var(Var::free(Name::user(field.name.clone()))).into(),
    };

    let parse_exprs = fields.iter().map(lower_to_field_parser);
    let expr_fields = fields.iter().map(lower_to_expr_field);

    let mut named_exprs = Vec::with_capacity(fields.len());
    let mut seen_names = Vec::<Ident>::with_capacity(fields.len());

    for (name, mut parse_expr) in parse_exprs {
        for (scope, name) in seen_names.iter().rev().enumerate() {
            parse_expr.abstract_names_at(&[Name::user(name.clone())], ScopeIndex(scope as u32));
        }

        seen_names.push(name.clone());
        named_exprs.push(Named::new(name, parse_expr));
    }

    let mut expr: RcExpr = Expr::Struct(path.clone(), expr_fields.collect()).into();
    for (scope, name) in seen_names.iter().rev().enumerate() {
        expr.abstract_names_at(&[Name::user(name.clone())], ScopeIndex(scope as u32));
    }

    ParseExpr::Sequence(named_exprs, expr).into()
}
/// Create a struct parser for the given fields
///
/// # Arguments
///
/// * `path` - path to the parent struct or union
/// * `fields` - the fields to be used in the parser
Create a struct parser for the given fields
Create a struct parser for the given fields
fn struct_parser(path: &Path, fields: &[Field<core::RcType>]) -> RcParseExpr {
    use var::ScopeIndex;
    let lower_to_field_parser = |field: &Field<core::RcType>| {
        (
            field.name.clone(),
            ty_parser(&path.append_child(field.name.0.clone()), &field.value),
        )
    };
    let lower_to_expr_field = |field: &Field<core::RcType>| Field {
        doc: Rc::clone(&field.doc),
        name: field.name.clone(),
        value: Expr::Var(Var::free(Name::user(field.name.clone()))).into(),
    };
    let parse_exprs = fields.iter().map(lower_to_field_parser);
    let expr_fields = fields.iter().map(lower_to_expr_field);
    let mut named_exprs = Vec::with_capacity(fields.len());
    let mut seen_names = Vec::<Ident>::with_capacity(fields.len());
    for (name, mut parse_expr) in parse_exprs {
        for (scope, name) in seen_names.iter().rev().enumerate() {
            parse_expr.abstract_names_at(&[Name::user(name.clone())], ScopeIndex(scope as u32));
        }
        seen_names.push(name.clone());
        named_exprs.push(Named::new(name, parse_expr));
    }
    let mut expr: RcExpr = Expr::Struct(path.clone(), expr_fields.collect()).into();
    for (scope, name) in seen_names.iter().rev().enumerate() {
        expr.abstract_names_at(&[Name::user(name.clone())], ScopeIndex(scope as u32));
    }
    ParseExpr::Sequence(named_exprs, expr).into()
}
fn struct_parser ( path : & Path , fields : & [ Field < core :: RcType > ] ) -> RcParseExpr { use var :: ScopeIndex ; let lower_to_field_parser = | field : & Field < core :: RcType > | { ( field . name . clone ( ) , ty_parser ( & path . append_child ( field . name . 0 . clone ( ) ) , & field . value ) , ) } ; let lower_to_expr_field = | field : & Field < core :: RcType > | Field { doc : Rc :: clone ( & field . doc ) , name : field . name . clone ( ) , value : Expr :: Var ( Var :: free ( Name :: user ( field . name . clone ( ) ) ) ) . into ( ) , } ; let parse_exprs = fields . iter ( ) . map ( lower_to_field_parser ) ; let expr_fields = fields . iter ( ) . map ( lower_to_expr_field ) ; let mut named_exprs = Vec :: with_capacity ( fields . len ( ) ) ; let mut seen_names = Vec :: < Ident > :: with_capacity ( fields . len ( ) ) ; for ( name , mut parse_expr ) in parse_exprs { for ( scope , name ) in seen_names . iter ( ) . rev ( ) . enumerate ( ) { parse_expr . abstract_names_at ( & [ Name :: user ( name . clone ( ) ) ] , ScopeIndex ( scope as u32 ) ) ; } seen_names . push ( name . clone ( ) ) ; named_exprs . push ( Named :: new ( name , parse_expr ) ) ; } let mut expr : RcExpr = Expr :: Struct ( path . clone ( ) , expr_fields . collect ( ) ) . into ( ) ; for ( scope , name ) in seen_names . iter ( ) . rev ( ) . enumerate ( ) { expr . abstract_names_at ( & [ Name :: user ( name . clone ( ) ) ] , ScopeIndex ( scope as u32 ) ) ; } ParseExpr :: Sequence ( named_exprs , expr ) . into ( ) }
Create a struct parser for the given fields
Create a struct parser for the given fields
path
&Path
fields
&[Field<core::RcType>]
path
&Path
fields
&[Field<core::RcType>]