util: add lifetime parameter to ReusableBoxFuture by Kestrer · Pull Request #3762 · tokio-rs/tokio (original) (raw)

Motivation

ReusableBoxFuture currently only supports 'static futures. However I don't think this limitation is necessary.

Solution

Add a lifetime parameter to ReusableBoxFuture that represents the lifetime of the contained future. ReusableBoxFuture<T> becomes ReusableBoxFuture<'static, T>.

This is a breaking change. If that's undesirable, this could potentially be added as a separate type (but I can't think of a good name for it).