Skip to content

There should be a way to mark blocks as pure. #2758

Closed
@paulstansifer

Description

@paulstansifer

The following code has to name two functions.

pure fn hash(x: @str) -> uint { str::hash(*x) }
pure fn eq(x: @str, y: @str) -> uint { str::eq(*x,*y) }
ret hashmap(hash, eq);

It'd be nice if we could write:

ret hashmap(pure {|x: @str|str::hash(*x)}, pure {|x,y|str::eq(*x,*y)});

...or even (with type inference, if possible):

ret hashmap({|x: @str|str::hash(*x)}, {|x,y|str::eq(*x,*y)});

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemC-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