Function ipcap::utils::single_level

source ·
pub fn single_level(value: &'static str) -> HashMap<&'static str, &'static str>
Expand description

Helper function to create a single-level hashmap.

This function takes a single value and wraps it in a hashmap with a default key “default”.

Arguments

  • value - The value to be stored in the hashmap.

Returns

(HashMap<&'static str, &'static str>): A map with a single entry.

Examples

use ipcap::utils::single_level;
use std::collections::HashMap;

let map: HashMap<&'static str, &'static str> = single_level("example_value");
assert_eq!(map.get("default"), Some(&"example_value"));
assert_eq!(map.len(), 1);