Fix no_std builds.

This commit is contained in:
Stephen Chung
2022-01-11 11:33:54 +08:00
parent 00255a9b78
commit 6dedb1ed9f
3 changed files with 37 additions and 6 deletions

View File

@@ -416,14 +416,16 @@ impl Engine {
.into())
}
Expr::Custom(custom, _) => {
Expr::Custom(custom, pos) => {
let expressions: StaticVec<_> = custom.inputs.iter().map(Into::into).collect();
// The first token acts as the custom syntax's key
let key_token = custom.tokens.first().unwrap();
// The key should exist, unless the AST is compiled in a different Engine
let custom_def = self.custom_syntax.get(key_token).ok_or_else(|| {
let code: Vec<_> = custom.tokens.iter().map(|s| s.as_str()).collect();
Box::new(ERR::ErrorSystem(
Box::new(ERR::ErrorCustomSyntax(
format!("Invalid custom syntax prefix: {}", key_token),
code.join(" ").into(),
custom.tokens.iter().map(|s| s.to_string()).collect(),
*pos,
))
})?;
let mut context = EvalContext {