Bumpalo's Box does not seem to work with dyn Future
- Dominant language
- Rust
- Stars
- 2.3k
- Forks
- 157
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 1
Description
To reduce memory allocations, I'm trying to use bumpalo to create my own Boxed futures type.
I'm basing this off of an idiom present in the futures crate:
```rust
type BoxFuture<'a, T> = Pin + 'a + Send>>;
```
https://docs.rs/futures/0.3.5/futures/future/type.BoxFuture.html
When I try this with bumpalo::boxed::Box, however, it seems that I can't convert an `impl Future` into a `dyn Future` the same way that I can with std::boxed::Box.
Here is some example code demonstrating the issue (I wish the playground had bumpalo!):
```rust
use std::future::Future;
use std::pin::Pin;
/// This compiles:
fn f(
fut: impl Future + Send + 'static,
) -> Pin + Send + 'static>> {
Box::pin(fut)
}
// This does not compile:
// fn g<'a>(
// b: &'a bumpalo::Bump,
// fut: impl Future + Send + 'static,
// ) -> Pin + Send + 'static>> {
// bumpalo::boxed::Box::pin_in(fut, &b)
// }
```
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=80eeec8261dc28169cfc968525ed7e43
Is there something I'm missing with how to use this library? Thank you!
Contributor guide
No contributing guide indexed for this repository
Research direction
The report names no repository files or tests; begin by reproducing the commented g example with bumpalo::boxed::Box::pin_in and compare it with f using std::boxed::Box. Done would require establishing whether bumpalo can box an impl Future as dyn Future, but the issue does not specify the expected implementation or outcome.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100