mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-04-25 09:22:19 +00:00
pass value not reference to fun
This commit is contained in:
parent
fab07adc5a
commit
15e6c6065b
@ -1027,7 +1027,11 @@ pub struct SelectorMut {
|
||||
value: Option<Value>,
|
||||
}
|
||||
|
||||
fn replace_value<F: FnMut(Value) -> Value>(mut tokens: Vec<String>, value: &mut Value, fun: &mut F) {
|
||||
fn replace_value<F: FnMut(Value) -> Value>(
|
||||
mut tokens: Vec<String>,
|
||||
value: &mut Value,
|
||||
fun: &mut F,
|
||||
) {
|
||||
let mut target = value;
|
||||
|
||||
let last_index = tokens.len() - 1;
|
||||
@ -1039,7 +1043,11 @@ fn replace_value<F: FnMut(Value) -> Value>(mut tokens: Vec<String>, value: &mut
|
||||
if is_last {
|
||||
if let Entry::Occupied(mut e) = map.entry(token) {
|
||||
let v = e.insert(Value::Null);
|
||||
e.insert(fun(v));
|
||||
if let Some(res) = fun(v) {
|
||||
e.insert(res);
|
||||
} else {
|
||||
e.remove();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user