MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / parse_tools

Method parse_tools

aiscript-vm/src/ai/agent.rs:137–154  ·  view source on GitHub ↗
(mut self, fields: &HashMap<&'gc str, Expr<'gc>>, mut f: F)

Source from the content-addressed store, hash-verified

135 }
136
137 pub fn parse_tools<F>(mut self, fields: &HashMap<&'gc str, Expr<'gc>>, mut f: F) -> Self
138 where
139 F: FnMut(&Token<'gc>) -> Option<FnDef>,
140 {
141 if let Some(Expr::List { elements, .. }) = fields.get("tools") {
142 for element in elements {
143 match element {
144 Expr::Variable { name, .. } => {
145 if let Some(fn_def) = f(name) {
146 self.tools.insert(name.lexeme.to_owned(), fn_def);
147 }
148 }
149 _ => panic!("Expected string literal"),
150 }
151 }
152 }
153 self
154 }
155}
156
157#[cfg(not(feature = "ai_test"))]

Callers 1

generate_stmtMethod · 0.80

Calls 1

getMethod · 0.45

Tested by

no test coverage detected