diff --git a/src/func/builtin.rs b/src/func/builtin.rs index 9052a5fe..075706fe 100644 --- a/src/func/builtin.rs +++ b/src/func/builtin.rs @@ -280,7 +280,7 @@ pub fn get_builtin_binary_op_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Option< Token::GreaterThanEqualsTo => Some(impl_op!(FLOAT => $xx >= $yy)), Token::LessThan => Some(impl_op!(FLOAT => $xx < $yy)), Token::LessThanEqualsTo => Some(impl_op!(FLOAT => $xx <= $yy)), - _ => None, + _ => None, }; } }; @@ -308,7 +308,7 @@ pub fn get_builtin_binary_op_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Option< Token::Divide => return Some(impl_op!(from Decimal => divide($xx, $yy))), Token::Modulo => return Some(impl_op!(from Decimal => modulo($xx, $yy))), Token::PowerOf => return Some(impl_op!(from Decimal => power($xx, $yy))), - _ => () + _ => () } #[cfg(feature = "unchecked")] @@ -322,17 +322,17 @@ pub fn get_builtin_binary_op_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Option< Token::Divide => return Some(impl_op!(from Decimal => $xx / $yy)), Token::Modulo => return Some(impl_op!(from Decimal => $xx % $yy)), Token::PowerOf => return Some(impl_op!(from Decimal => $xx.powd($yy))), - _ => () + _ => () } return match op { - Token::EqualsTo => Some(impl_op!(from Decimal => $xx == $yy)), - Token::NotEqualsTo => Some(impl_op!(from Decimal => $xx != $yy)), - Token::GreaterThan => Some(impl_op!(from Decimal => $xx > $yy)), - Token::GreaterThanEqualsTo => Some(impl_op!(from Decimal => $xx >= $yy)), - Token::LessThan => Some(impl_op!(from Decimal => $xx < $yy)), - Token::LessThanEqualsTo => Some(impl_op!(from Decimal => $xx <= $yy)), - _ => None + Token::EqualsTo => Some(impl_op!(from Decimal => $xx == $yy)), + Token::NotEqualsTo => Some(impl_op!(from Decimal => $xx != $yy)), + Token::GreaterThan => Some(impl_op!(from Decimal => $xx > $yy)), + Token::GreaterThanEqualsTo => Some(impl_op!(from Decimal => $xx >= $yy)), + Token::LessThan => Some(impl_op!(from Decimal => $xx < $yy)), + Token::LessThanEqualsTo => Some(impl_op!(from Decimal => $xx <= $yy)), + _ => None }; } }; @@ -680,7 +680,7 @@ pub fn get_builtin_op_assignment_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Opt Token::DivideAssign => Some(impl_op!($x /= $yy)), Token::ModuloAssign => Some(impl_op!($x %= $yy)), Token::PowerOfAssign => Some(impl_op!($x => $xx.powf($yy as $x))), - _ => None, + _ => None, }; } } @@ -707,7 +707,7 @@ pub fn get_builtin_op_assignment_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Opt Token::DivideAssign => Some(impl_op!(from $x => divide($xx, $yy))), Token::ModuloAssign => Some(impl_op!(from $x => modulo($xx, $yy))), Token::PowerOfAssign => Some(impl_op!(from $x => power($xx, $yy))), - _ => None, + _ => None, }; #[cfg(feature = "unchecked")] @@ -715,13 +715,13 @@ pub fn get_builtin_op_assignment_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Opt #[cfg(feature = "unchecked")] return match op { - Token::PlusAssign => Some(impl_op!(from $x += $yy)), - Token::MinusAssign => Some(impl_op!(from $x -= $yy)), - Token::MultiplyAssign => Some(impl_op!(from $x *= $yy)), - Token::DivideAssign => Some(impl_op!(from $x /= $yy)), - Token::ModuloAssign => Some(impl_op!(from $x %= $yy)), - Token::PowerOfAssign => Some(impl_op!(from $x => $xx.powd($yy))), - _ => None, + Token::PlusAssign => Some(impl_op!(from $x += $yy)), + Token::MinusAssign => Some(impl_op!(from $x -= $yy)), + Token::MultiplyAssign => Some(impl_op!(from $x *= $yy)), + Token::DivideAssign => Some(impl_op!(from $x /= $yy)), + Token::ModuloAssign => Some(impl_op!(from $x %= $yy)), + Token::PowerOfAssign => Some(impl_op!(from $x => $xx.powd($yy))), + _ => None, }; } }; diff --git a/src/optimizer.rs b/src/optimizer.rs index 6ab19fcb..c46cf43f 100644 --- a/src/optimizer.rs +++ b/src/optimizer.rs @@ -254,7 +254,7 @@ fn optimize_stmt_block( }); // Optimize each statement in the block - for stmt in statements.iter_mut() { + for stmt in &mut statements { match stmt { Stmt::Var(x, options, ..) => { if options.contains(ASTFlags::CONSTANT) { @@ -688,7 +688,7 @@ fn optimize_stmt(stmt: &mut Stmt, state: &mut OptimizerState, preserve_result: b optimize_expr(match_expr, state, false); // Optimize blocks - for b in expressions.iter_mut() { + for b in expressions.as_mut() { optimize_expr(&mut b.condition, state, false); optimize_expr(&mut b.expr, state, false); @@ -1204,7 +1204,7 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, _chaining: bool) { x.args.iter_mut().for_each(|a| optimize_expr(a, state, false)); // Move constant arguments - for arg in x.args.iter_mut() { + for arg in &mut x.args { match arg { Expr::DynamicConstant(..) | Expr::Unit(..) | Expr::StringConstant(..) | Expr::CharConstant(..) @@ -1254,7 +1254,7 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, _chaining: bool) { } // id(args ..) or xxx.id(args ..) -> optimize function call arguments - Expr::FnCall(x, ..) | Expr::MethodCall(x, ..) => for arg in x.args.iter_mut() { + Expr::FnCall(x, ..) | Expr::MethodCall(x, ..) => for arg in &mut x.args { optimize_expr(arg, state, false); // Move constant arguments diff --git a/src/packages/array_basic.rs b/src/packages/array_basic.rs index 21abbde9..72e2347e 100644 --- a/src/packages/array_basic.rs +++ b/src/packages/array_basic.rs @@ -834,7 +834,7 @@ pub mod array_functions { return Ok(false); } - for item in array.iter_mut() { + for item in array { if ctx .call_fn_raw(OP_EQUALS, true, false, &mut [item, &mut value.clone()]) .or_else(|err| match *err { diff --git a/src/types/dynamic.rs b/src/types/dynamic.rs index c1fe1dcf..db88b9fa 100644 --- a/src/types/dynamic.rs +++ b/src/types/dynamic.rs @@ -928,7 +928,7 @@ impl Dynamic { #[cfg(not(feature = "no_index"))] Union::Array(ref mut a, _, ref mut access) => { *access = typ; - for v in a.iter_mut() { + for v in a.as_mut() { v.set_access_mode(typ); } }