Simplify Dynamic::as_XXX calls.

This commit is contained in:
Stephen Chung
2022-11-09 20:18:11 +08:00
parent ce046422f0
commit a1d42b826a
5 changed files with 66 additions and 54 deletions

View File

@@ -52,7 +52,6 @@ impl Engine {
global: &mut GlobalRuntimeState,
caches: &mut Caches,
lib: &[SharedModule],
scope: &'s mut Scope,
this_ptr: &'s mut Dynamic,
expr: &Expr,
@@ -136,7 +135,6 @@ impl Engine {
global: &mut GlobalRuntimeState,
caches: &mut Caches,
lib: &[SharedModule],
scope: &'s mut Scope,
this_ptr: &'s mut Dynamic,
expr: &Expr,
@@ -221,7 +219,6 @@ impl Engine {
global: &mut GlobalRuntimeState,
caches: &mut Caches,
lib: &[SharedModule],
scope: &mut Scope,
this_ptr: &mut Dynamic,
expr: &Expr,

View File

@@ -6,7 +6,7 @@ use crate::ast::{
ASTFlags, BinaryExpr, Expr, Ident, OpAssignment, Stmt, SwitchCasesCollection, TryCatchBlock,
};
use crate::func::{get_builtin_op_assignment_fn, get_hasher};
use crate::types::dynamic::{AccessMode, Union};
use crate::types::dynamic::AccessMode;
use crate::types::RestoreOnDrop;
use crate::{
Dynamic, Engine, ImmutableString, Position, RhaiResult, RhaiResultOf, Scope, SharedModule, ERR,
@@ -687,7 +687,7 @@ impl Engine {
.map(|_| Dynamic::UNIT)
.map_err(|result_err| match *result_err {
// Re-throw exception
ERR::ErrorRuntime(Dynamic(Union::Unit(..)), pos) => {
ERR::ErrorRuntime(v, pos) if v.is_unit() => {
err.set_position(pos);
err
}