Change Dynamic to enum.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::any::{Any, Dynamic};
|
||||
use crate::any::Dynamic;
|
||||
use crate::engine::{
|
||||
Engine, FnAny, FnCallArgs, FnSpec, FunctionsLib, KEYWORD_DEBUG, KEYWORD_EVAL, KEYWORD_PRINT,
|
||||
KEYWORD_TYPE_OF,
|
||||
@@ -116,7 +116,7 @@ fn call_fn(
|
||||
) -> Result<Option<Dynamic>, EvalAltResult> {
|
||||
let spec = FnSpec {
|
||||
name: fn_name.into(),
|
||||
args: args.iter().map(|a| Any::type_id(*a)).collect(),
|
||||
args: args.iter().map(|a| a.type_id()).collect(),
|
||||
};
|
||||
|
||||
// Search built-in's and external functions
|
||||
@@ -570,7 +570,7 @@ fn optimize_expr<'a>(expr: Expr, state: &mut State<'a>) -> Expr {
|
||||
}
|
||||
|
||||
let mut arg_values: Vec<_> = args.iter().map(Expr::get_constant_value).collect();
|
||||
let mut call_args: Vec<_> = arg_values.iter_mut().map(Dynamic::as_mut).collect();
|
||||
let mut call_args: Vec<_> = arg_values.iter_mut().collect();
|
||||
|
||||
// Save the typename of the first argument if it is `type_of()`
|
||||
// This is to avoid `call_args` being passed into the closure
|
||||
@@ -585,7 +585,7 @@ fn optimize_expr<'a>(expr: Expr, state: &mut State<'a>) -> Expr {
|
||||
result.or_else(|| {
|
||||
if !arg_for_type_of.is_empty() {
|
||||
// Handle `type_of()`
|
||||
Some(arg_for_type_of.to_string().into_dynamic())
|
||||
Some(Dynamic::from_string(arg_for_type_of.to_string()))
|
||||
} else {
|
||||
// Otherwise use the default value, if any
|
||||
def_value.clone()
|
||||
|
Reference in New Issue
Block a user