Skip to content

Feature request: #[call_generic] macro #19

@coriolinus

Description

@coriolinus

After experimenting a little bit with this crate, it seems apparent that deeply nested code suffers a bit. Any time an #[async_generic] function calls another #[async_generic] function, you need the same little bit of boilerplate:

#[async_generic]
fn bar() {
    if _sync {
        foo();
    } else {
        foo_async().await;
    }
}

It would be great if we could collapse that pattern down, like this:

#[async_generic]
fn bar() {
    #[call_generic]
    foo();
}

There are obvious limitations to such an attribute macro, which can't recursively apply itself to all relevant functions. So I'd propose that it only applies to the outermost function in the statement. But it should still apply properly to free functions, associated functions, and methods.

Would you be positively inclined toward a PR adding this feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions