I have a function that takes in a Mut<'_, dyn Reflect> and a string. It first calls .reflect_mut() on that. if the ReflectMut is a struct it will return a &mut dyn Reflect to the ReflectMut's field with the name of the string you pass in to the function.
The problem is this error:
error[E0515]: cannot return value referencing local variable `var`
|
473 | let reflect_mut = var.reflect_mut();
| --- `var` is borrowed here
...
487 | Ok(field)
| ^^^^^^^^^^^^^^^^^ returns a value referencing data owned by the current function
Context: var is a Mut<'_, dyn Reflect>
the what