pub fn map_to_const<'a, K: ExtTypeName + Debug + Ord, V: ExtTypeName + Debug>(
    map: &HashMap<K, V>,
    const_name: impl Into<Option<&'a str>>
) -> String
Expand description

Converts a HashMap<K, V> to a const or constant [(K, V); N] string representation, where N is the number of key-value pairs in the input map object.

Example

use map_to_const::*;

let const_value = map_to_const(
  &std::collections::HashMap::from([("hello", "world"), ("testing", "123")]),
  "my_const_name"
);

Errors

Panics if the input HashMap object is empty.