Skip to content

Consider closure autoref #21699

@nikomatsakis

Description

@nikomatsakis

We could have a || expression expand to &F or &mut F where F : Fn() (FnMut, etc), and not just F. This would make it easier to write code that accepted boxed closures:

fn foo(x: &mut FnMut()) { ... }
foo(|| ...)

whereas today it is required to write:

foo(&mut || ...)

This seems like a pretty small delta and might go a long way towards improving ergonomic impact of the new closure design.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-closuresArea: Closures (`|…| { … }`)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions