pub fn add_item_to_namespace(
        &mut self,
        name: Ident,
        mod_def: ModuleDefId,
    ) -> Result<(), (Ident, Ident)> {
        match &mod_def {
            ModuleDefId::ModuleId(_) => {
                if let Entry::Occupied(o) = self.types.entry(name.clone()) {
                    let old_ident = o.key();
                    return Err((old_ident.clone(), name));
                }

                self.types.insert(name, (mod_def, Visibility::Public))
            }
            ModuleDefId::FunctionId(_) => {
                if let Entry::Occupied(o) = self.values.entry(name.clone()) {
                    let old_ident = o.key();
                    return Err((old_ident.clone(), name));
                }

                self.values.insert(name, (mod_def, Visibility::Public))
            }
        };
        Ok(())
    }
/// Returns an Err if there is already an item
/// in the namespace with that exact name.
/// The Err will return (old_item, new_item)
Returns an Err if there is already an item
in the namespace with that exact name.
Returns an Err if there is already an item in the namespace with that exact name .
pub fn add_item_to_namespace(
        &mut self,
        name: Ident,
        mod_def: ModuleDefId,
    ) -> Result<(), (Ident, Ident)> {
        match &mod_def {
            ModuleDefId::ModuleId(_) => {
                if let Entry::Occupied(o) = self.types.entry(name.clone()) {
                    let old_ident = o.key();
                    return Err((old_ident.clone(), name));
                }
                self.types.insert(name, (mod_def, Visibility::Public))
            }
            ModuleDefId::FunctionId(_) => {
                if let Entry::Occupied(o) = self.values.entry(name.clone()) {
                    let old_ident = o.key();
                    return Err((old_ident.clone(), name));
                }
                self.values.insert(name, (mod_def, Visibility::Public))
            }
        };
        Ok(())
    }
pub fn add_item_to_namespace ( & mut self , name : Ident , mod_def : ModuleDefId , ) -> Result < ( ) , ( Ident , Ident ) > { match & mod_def { ModuleDefId :: ModuleId ( _ ) => { if let Entry :: Occupied ( o ) = self . types . entry ( name . clone ( ) ) { let old_ident = o . key ( ) ; return Err ( ( old_ident . clone ( ) , name ) ) ; } self . types . insert ( name , ( mod_def , Visibility :: Public ) ) } ModuleDefId :: FunctionId ( _ ) => { if let Entry :: Occupied ( o ) = self . values . entry ( name . clone ( ) ) { let old_ident = o . key ( ) ; return Err ( ( old_ident . clone ( ) , name ) ) ; } self . values . insert ( name , ( mod_def , Visibility :: Public ) ) } } ; Ok ( ( ) ) }
Returns an Err if there is already an item
in the namespace with that exact name.
Returns an Err if there is already an item in the namespace with that exact name .
&mut self
name
Ident
mod_def
ModuleDefId
&mut self
name
Ident
mod_def
ModuleDefId