pub fn definitions_iter(
        &self,
        mut func: impl FnMut(&ast::Id, &mut Component) -> Result<()>,
    ) -> Result<()> {
        let mut definitions = self.definitions.borrow_mut();

        // do main iteration
        let ret = definitions
            .iter_mut()
            .map(|(id, comp)| func(id, comp))
            .collect();

        // if there are new definitions to insert, insert them now
        let mut defns_to_insert = self.definitions_to_insert.borrow_mut();
        for new_defn in defns_to_insert.drain(..) {
            definitions.insert(new_defn.name.clone(), new_defn);
        }

        ret
    }
// XXX(sam) maybe implement this as an iterator?
/// Iterates over the context definitions, giving mutable access the components
XXX(sam) maybe implement this as an iterator.
Iterates over the context definitions, giving mutable access the components
XXX ( sam ) maybe implement this as an iterator . Iterates over the context definitions giving mutable access the components
pub fn definitions_iter(
        &self,
        mut func: impl FnMut(&ast::Id, &mut Component) -> Result<()>,
    ) -> Result<()> {
        let mut definitions = self.definitions.borrow_mut();
        // do main iteration
        let ret = definitions
            .iter_mut()
            .map(|(id, comp)| func(id, comp))
            .collect();
        // if there are new definitions to insert, insert them now
        let mut defns_to_insert = self.definitions_to_insert.borrow_mut();
        for new_defn in defns_to_insert.drain(..) {
            definitions.insert(new_defn.name.clone(), new_defn);
        }
        ret
    }
pub fn definitions_iter ( & self , mut func : impl FnMut ( & ast :: Id , & mut Component ) -> Result < ( ) > , ) -> Result < ( ) > { let mut definitions = self . definitions . borrow_mut ( ) ; // do main iteration let ret = definitions . iter_mut ( ) . map ( | ( id , comp ) | func ( id , comp ) ) . collect ( ) ; // if there are new definitions to insert, insert them now let mut defns_to_insert = self . definitions_to_insert . borrow_mut ( ) ; for new_defn in defns_to_insert . drain ( .. ) { definitions . insert ( new_defn . name . clone ( ) , new_defn ) ; } ret }
XXX(sam) maybe implement this as an iterator?
XXX ( sam ) maybe implement this as an iterator?
&self
func
impl FnMut(&ast::Id, &mut Component) -> Result<()>