Skip to content

Quick initializer for maps #1420

@domoritz

Description

@domoritz

Especially in tests it can be extremely helpful to quickly initialize a map. Right now, you have to create an empty map and call insert a couple of times.

fn main() {
    let vec = [1, 2, 3, 4];
    print!("{:?}", vec);

    let map = {"foo": 0, "bar": 1};
//              ^^^^^^^^^^^
//              does not work
    print!("{:?}", map);
}

See example at http://is.gd/P0yeNQ

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team, which will review and decide on the RFC.T-libs-apiRelevant to the library API team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions