Skip to content

RFC: Integrate capture clause into parameter list #2096

Closed
@nikomatsakis

Description

@nikomatsakis

Currently, a capture clause is written:

fn@[move x, y; copy z](a: T) { ... }

I was thinking that maybe we should write it inline with the parameters, like so:

fn@(a: T; move x, y; copy z) { ... }

The reasons are (1) I find it easier to read but also (2) it integrates with the sugared closures better:

task::spawn {|move x, y; copy z|
    ...
}

In general, then, the parameter list for a closure would have three parts:

  • the normal parameters
  • the move mode captures
  • the copy mode captures

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions