const_hashmap

Macro const_hashmap 

Source
const_hashmap!() { /* proc-macro */ }
Expand description

Siempre exportamos el macro const_hashmap! y const_hashmap_const! Macro that generates a ConstMap from a list of key-value pairs.

Example:

#![feature(const_trait_impl)]
use const_hashmap_macros::const_hashmap;
const_hashmap! {
     pub const COLORS: &str => u8 = {
         "red"   => 0,
         "green" => 1,
         "blue"  => 2,
     };
 }

Generates:

 #![feature(const_trait_impl)]
 pub const COLORS: const_hashmap::ConstMap<&str, u8, 8> = {
     const_hashmap::build_map::<&str, u8, 8>(&[
         ("red",   0),
         ("green", 1),
         ("blue",  2),
     ])
 };