Skip to content

Commit

Permalink
Fix bug in Dynamic::deep_scan.
Browse files Browse the repository at this point in the history
  • Loading branch information
schungx committed Jun 24, 2023
1 parent ee64fd9 commit 03b1a1c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Rhai Release Notes
==================

Version 1.16.0
==============

Bug fixes
---------

* `Dynamic::deep_scan` is fixed so now it properly scans arrays, object maps and function pointers embedded inside data.


Version 1.15.0
==============

Expand All @@ -14,6 +23,7 @@ Enhancements

* Expressions involving `this` should now run slightly faster due to a dedicated `AST` node `ThisPtr`.
* A `take` function is added to the standard library to take ownership of any data (replacing with `()`) in order to avoid cloning.
* `Dynamic::take` is added to take ownership of the data (replacing with `()`) in order to avoid cloning.
* `EvalAltResult::ErrorMismatchOutputType` now gives a better name for the requested generic type (e.g. `&str` is now `&str` and not `string`).


Expand Down
3 changes: 2 additions & 1 deletion src/types/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,8 @@ impl Dynamic {
#[allow(clippy::only_used_in_recursion)]
pub fn deep_scan(&mut self, mut filter: impl FnMut(&mut Self)) {
fn scan_inner(value: &mut Dynamic, filter: &mut impl FnMut(&mut Dynamic)) {
filter(value);

match &mut value.0 {
#[cfg(not(feature = "no_index"))]
Union::Array(a, ..) => a.iter_mut().for_each(|v| scan_inner(v, filter)),
Expand All @@ -2117,7 +2119,6 @@ impl Dynamic {
}
}

filter(self);
scan_inner(self, &mut filter);
}
}
Expand Down

0 comments on commit 03b1a1c

Please sign in to comment.