This is confusing, and Rust's error messages make it much worse. If you try to remove the `move`, you get an error:
> closure may outlive the current function, but it borrows `answer`, which is owned by the current function. To force the closure to take ownership of `answer` use the `move` keyword.
But 'answer' is of course not owned by the current function, and how can you take ownership through a shared reference?
The explanation is double indirection. By default, the closure captures a pointer to answer, which is itself a pointer on the stack. Without the 'move', inside the closure `answer` has type &&str and points into make_tester's stack frame. With the 'move', it copies the passed-in pointer. The error message is referring to the pointer itself, and this is not obvious.
Incidentally I have never found docs for the '+' syntax there, would appreciate a pointer to any.
> But 'answer' is of course not owned by the current function
As you imply later, ‘answer’ itself is owned by the current function, but the ‘answer’ value is a pointer that doesn’t own what it points to. This subtlety, that references are full values themselves, is definitely something to trip on, especially when double indirection starts popping up like this.
> closure may outlive the current function, but it borrows `answer`, which is owned by the current function. To force the closure to take ownership of `answer` use the `move` keyword.
But 'answer' is of course not owned by the current function, and how can you take ownership through a shared reference?
The explanation is double indirection. By default, the closure captures a pointer to answer, which is itself a pointer on the stack. Without the 'move', inside the closure `answer` has type &&str and points into make_tester's stack frame. With the 'move', it copies the passed-in pointer. The error message is referring to the pointer itself, and this is not obvious.
Incidentally I have never found docs for the '+' syntax there, would appreciate a pointer to any.