#dyn #future #futures #promise #dynamic


Convenient and fast dynamic Futures for Rust

14 stable releases

3.0.4 Dec 4, 2019
3.0.1 Dec 3, 2019
2.1.3 Dec 3, 2019
1.0.1 Dec 2, 2019

#268 in Asynchronous

Download history 14/week @ 2020-10-23 18/week @ 2020-11-27 13/week @ 2020-12-04 15/week @ 2020-12-11 1/week @ 2021-01-22 14/week @ 2021-02-05

71 downloads per month

MIT license

165 lines


This is a small crate implementing convenient and fast dynamic Futures in Rust.

The DynFuture<T> type this library provides is intended as a replacement for the naive Box<dyn Future<Output = T>>.


This library is designed to be dead simple to use and require no setup. You can freely mix the naive boxed futures from dependencies and such without issue.

DynFuture<T> can be used the same way as Box<dyn Future<Output = T>> and most of the time you can just run find and replace on your existing code.

DynFuture<T> can be awaited like any other future, but it has a fixed size.

It should only be used as a replacement for Box<dyn Future<Output = T>>. If it is possible you should always prefer statically resolved futures using async fn.

Compilation overhead

dyn-future strives to be small and to minimize dependencies. If you have any questions or improvements to make, feel free to open an issue.


The provided DynFuture<T> type is faster than the naive implementation. Exactly how much depends on the global allocator, amount of CPU logical processors and the sizes of the futures sent. Though in general DynFuture<T> is always faster.

Currently we provide some extremely simple benchmarks. These could absolutely be improved. This is something I would like help with as I am not fantastic at writing benchmarks.

There are not representative of real world gains due to the lack of variation of future types. I have done some minor benchmarking of a proprietary codebase using dyn-future with over 8x gains in time spent handling dynamic futures.


dyn-future gladly accepts contributions!

Open a PR and I will take a look.