boxpin
boxpin is a tiny Rust crate that exposes Box::pin(...) as a readable suffix:
use BoxPinExt;
let future = async .pinned;
let value = block_on;
assert_eq!;
It does not perform type erasure and it does not return BoxFuture.
It is exactly equivalent to:
let future = Boxpin;
Why
This repo started as a benchmark project comparing .boxed() and Box::pin().
.boxed() is often nicer to read in suffix-heavy async code, but it also adds
type erasure and dynamic dispatch. boxpin keeps the suffix ergonomics while
preserving the concrete type inside Pin<Box<T>>.
Crate API
The trait is implemented for every Sized type, so .pinned() also works for
plain values, not just futures.
Local Benchmarks
This repository still contains the local Criterion benchmark harness used to compare:
- no boxing
Box::pin(...).boxed()
Run it with: