Skip to content

FutureObj::from only allows Output = () #1347

Closed
@realcr

Description

@realcr

Hi, I have seen this piece of code at alloc/boxed.rs (Futures 0.3.0-alpha.9):

#[unstable(feature = "futures_api", issue = "50547")]
impl<'a, F: Future<Output = ()> + Send + 'a> From<Box<F>> for FutureObj<'a, ()> {
    fn from(boxed: Box<F>) -> Self {
        FutureObj::new(boxed)
    }
}

Full listing here: https://doc.rust-lang.org/src/alloc/boxed.rs.html#833-837

I have a future that returns an output that is not (). When I tried to compile:

FutureObj::from(fut.boxed())

I was surprised to find out that () is the only Output supported for FutureObj::from. As a workaround I am using FutureObj::new. Is this behaviour intentional? I apologize ahead of time if I'm asking something trivial here, I'm still new to this codebase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions