Skip to content

Tracking Issue for hash_map! macro #144032

@stifskere

Description

@stifskere

Feature gate: #![feature(hash_map_macro)]

This is a tracking issue for rust-lang/libs-team#578

The hash_map! macro is like the vec! macro but for HashMaps, it aims to help create hash_maps with set keys for functions that require dynamic key value pairs such as a templating engine asking to fill the templates with a HashMap.

Public API

use std::hash_map;

fn main() {
    let map = hash_map![
        "key" => "value",
        "key2" => "value2"
    ]; // uses type inference.

    for (key, value) in map {
        println!("{key:?} => {value:?}");
    }
}

Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

Unresolved Questions

  • What separator should we use? the main proposition was =>, : was also proposed.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.T-langRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions