Will the closure cause any performance problems? I suppose it's possible for the compiler to optimise that case, but is it reasonable to expect that?
If so, that seems like a good solution. Otherwise loop { ... } it will have to be. I'm also wondering if either of these solutions would be considered idiomatic in rust.
I would expect the compiler to optimize them all to roughly the same code, but that’s just a guess. Though I’m not sure if there would be any risk with loop/closure to anger the borrow checker. @Michael-F-Bryan’s solution is certainly cleaner though and easier for the compiler to optimize. I guess you could take that a step further And just do this for this case.