Macro rocket_contrib::map [] [src]

macro_rules! map {
    ($($key:expr => $value:expr),+) => { ... };
    ($($key:expr => $value:expr),+,) => { ... };
}

A nice little macro to create simple HashMaps. Really convenient for returning ad-hoc JSON messages.

Examples

use std::collections::HashMap;
let map: HashMap<&str, usize> = map! {
    "status" => 0,
    "count" => 100
};

assert_eq!(map.len(), 2);
assert_eq!(map.get("status"), Some(&0));
assert_eq!(map.get("count"), Some(&100));