Skip to content

Add explicit notion of copyability for closures. #2829

@bblum

Description

@bblum

Proposal: A closure is copyable iff everything in its environment is copyable. Furthermore, non-copyable ("one-shot") closures are allowed to capture and de-initialise outer variables.

This will allow building closures that run destructors for you. It will also fix #2828.

Closures' types can then be written with copy and send traits. fn x(f: fn()) { f(); f(); } will no longer be legal; you have to write fn x(f: fn()<copy>) or some-such.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemE-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions