Best practices for NonlinearSolve definition with temporary arrays

I did something akin to it. What @JonasWickman suggested works to make the function type stable. Other useful solutions imply using @unpack or @pack similar to this.