Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Benchmarking a function returning borrowed data #285
Thanks for the quick reply :) I tried _ref but I’m not getting it to work sadly. I think it is about the lifetime of the input not he output in _ref? But I could be wrong - lifetimes are still my arch nemesis in rust -.- what I’m trying to do is get rid of this semicolon so that the drop happens outside the benchmark loop.
Ah, I see what you mean now.
Unfortunately, I don't think that's currently possible. Worse, I'm not even certain that it's possible for Criterion.rs to support that. It ought to be safe - the returned reference should never outlive the input - but I have no idea how to convince rustc of that.
Sorry I can't be more helpful. I'll leave this open in case somebody out there knows some lifetime trickery I don't know. I've put up a minimal test case on the Playground in case anyone wants to take a go.