Registers the given builtin callable, which must not yet be registered.
(&mut self, callable: Rc<dyn Callable>)
| 288 | |
| 289 | /// Registers the given builtin callable, which must not yet be registered. |
| 290 | pub fn add_callable(&mut self, callable: Rc<dyn Callable>) { |
| 291 | let metadata = callable.metadata(); |
| 292 | let key = SymbolKey::from(metadata.name()); |
| 293 | |
| 294 | let previous = self.callables.insert(key.clone(), callable); |
| 295 | debug_assert!(previous.is_none(), "Cannot insert a callable twice"); |
| 296 | |
| 297 | let previous = self.callables_metadata.borrow_mut().insert(key, metadata); |
| 298 | debug_assert!(previous.is_none(), "Cannot insert callable metadata twice"); |
| 299 | } |
| 300 | |
| 301 | /// Returns metadata for all callables currently registered in the builder. |
| 302 | pub fn callables_metadata(&self) -> Rc<RefCell<HashMap<SymbolKey, Rc<CallableMetadata>>>> { |