Skip to content

Implement Actor for async function without result #164

@Thomasdezeeuw

Description

@Thomasdezeeuw

Currently example 1b has the following actor.

async fn greeter_actor(_: Context<!>) -> Result<(), !> {
    println!("Hello World");
    Ok(())
}

I would like to following to be possible

async fn greeter_actor(_: Context<!>)  { // Returns `()`.
    println!("Hello World");
}

The following implementation doesn't work as it overlaps with our implementation for Future<Output = Result(), E>.

impl<Fut> Actor for Fut
    where Fut: Future<Output = ()>
{
    type Error = !;

    fn try_poll(self: Pin<&mut Self>, waker: &LocalWaker) -> Poll<Result<(), Self::Error>> {
        self.poll(waker).map(Ok)
    }
}

This requires rust-lang/rfcs#1672.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ideaAn idea, open to discussion.priority:lowLow priority issue.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions