New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bumpalo's Box does not seem to work with dyn Future #82
Comments
I think that the standard library You should be able to create a And if we had a public, unsafe constructor for
You would probably want to wrap that up in a method (unfortunately, I don't think the type system can express this generically, so we can't do it in this crate). I think an unsafe constructor is reasonable to support, so if you want to open a PR, I can review+merge it. |
@fitzgen Would the function look like this? impl<'a, T: ?Sized> Box<'a, T> {
#[inline]
pub unsafe fn from_mut(x: &mut T) -> Self {
Box(x)
} or impl<'a, T: ?Sized> Box<'a, T> {
#[inline]
pub unsafe fn from_mut(x: &mut T) -> Self {
Box(&mut *x)
} |
It would look like the first, but additionally the parameter would use the |
However it doesn't work too well. The fact that |
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:
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 adyn 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!):
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!
The text was updated successfully, but these errors were encountered: