Hello,
I have stuck with this issue where I pass a reference to function(e.g. fn_1) to another function(fn_2) and call fn_1 inside fn_2 with a variable created inside fn_2. The Issue is fn_1 takes references and hence I have to provide lifetimes. But I can't find way to get past this error.
Below is a small snippet shows what I am trying to do.
fn call_fn<'b, F>(v1: &'b Value, mut fn_: F) -> Value
where F: for<'a> FnMut(&'a mut Value, &'b Value) -> &'a Value{
let mut v2 = Value{v:0};
let _ = fn_(&mut v2, &v1);
v2
}
Your original version takes 'a as a parameter from outside. This means it refers to a stack frame outside of call_fn, which prevents any &'a reference pointing to a local variable.