Function map_to_const::map_to_const
source · [−]pub fn map_to_const<'a, K: ExtTypeName + Debug + Ord, V: ExtTypeName + Debug>(
map: &HashMap<K, V>,
const_name: impl Into<Option<&'a str>>
) -> StringExpand 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.