Add lifetime bounds to the path-finding structs

The caller can still specify the `'static` bound if they wish the closure to
escape the stack frame, but this lets us use the by-ref closures as well.