fn parse_program_mod(ctx: &CrateContext) -> syn::ItemMod {
    let root = ctx.root_module();
    let mods = root
        .items()
        .filter_map(|i| match i {
            syn::Item::Mod(item_mod) => {
                let mod_count = item_mod
                    .attrs
                    .iter()
                    .filter(|attr| attr.path.segments.last().unwrap().ident == "program")
                    .count();
                if mod_count != 1 {
                    return None;
                }
                Some(item_mod)
            }
            _ => None,
        })
        .collect::<Vec<_>>();
    if mods.len() != 1 {
        panic!("Did not find program attribute");
    }
    mods[0].clone()
}
// Parse the main program mod.
Parse the main program mod.
Parse the main program mod .
fn parse_program_mod(ctx: &CrateContext) -> syn::ItemMod {
    let root = ctx.root_module();
    let mods = root
        .items()
        .filter_map(|i| match i {
            syn::Item::Mod(item_mod) => {
                let mod_count = item_mod
                    .attrs
                    .iter()
                    .filter(|attr| attr.path.segments.last().unwrap().ident == "program")
                    .count();
                if mod_count != 1 {
                    return None;
                }
                Some(item_mod)
            }
            _ => None,
        })
        .collect::<Vec<_>>();
    if mods.len() != 1 {
        panic!("Did not find program attribute");
    }
    mods[0].clone()
}
fn parse_program_mod ( ctx : & CrateContext ) -> syn :: ItemMod { let root = ctx . root_module ( ) ; let mods = root . items ( ) . filter_map ( | i | match i { syn :: Item :: Mod ( item_mod ) => { let mod_count = item_mod . attrs . iter ( ) . filter ( | attr | attr . path . segments . last ( ) . unwrap ( ) . ident == " " ) . count ( ) ; if mod_count != 1 { return None ; } Some ( item_mod ) } _ => None , } ) . collect :: < Vec < _ > > ( ) ; if mods . len ( ) != 1 { panic ! ( " " ) ; } mods [ 0 ] . clone ( ) }
Parse the main program mod.
Parse the main program mod .
ctx
&CrateContext