Skip to content

Allow using Fn(A, B, C) -> _ for unconstrained FnOnce::Output. #47815

@eddyb

Description

@eddyb

F: Fn(A, B, C) -> R desugars to F: Fn<(A, B, C), Output = R> currently.
F: Fn(A, B, C) -> _ could easily desugar to F: Fn<(A, B, C)>.
More generally, we can allow T: Trait<AssocTy = _>, meaning the same as T: Trait.

This form would make it easier to be generic over the return type without having to specify it as another generic parameter (which is worse in type definitions than impls, as it leaks to users).

cc @eternaleye (who suggested it) @nikomatsakis @withoutboats @Centril

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-langRelevant to the language team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions