Function parse_hashmap

Source
pub fn parse_hashmap(
    input: Vec<String>,
    unescape: bool,
) -> HashMap<String, Option<String>>
Expand description

Parse response as hashmap

unescape: if true unescapes values, can be turned off to boost performance on known response types (like numbers)

use ts3_query::*;
use std::collections::HashMap;

let input: Vec<String> = vec!["clid=28631 cid=9391 foo","client_type=1",""]
    .into_iter().map(ToOwned::to_owned).collect();
let expected: HashMap<String, Option<String>> = vec![
    ("clid",Some("28631")),
    ("cid",Some("9391")),
    ("foo",None),
    ("client_type",Some("1"))]
    .into_iter().map(|(x,y)|(x.to_owned(),y.map(|y|y.to_owned()))).collect();
assert_eq!(expected,raw::parse_hashmap(input,false));