clia_url_qs/
from_hashmap.rs1use anyhow::Result;
2use serde::Serialize;
3
4pub fn from_hashmap<T: Serialize + ?Sized>(arr: &T) -> Result<String> {
16 serde_urlencoded::to_string(arr).map_err(|e| e.into())
17}
18
19#[cfg(test)]
20mod tests {
21 use std::collections::HashMap;
22
23 use super::*;
24
25 #[test]
26 fn test_from_hashmap() {
27 let mut params = HashMap::new();
28 params.insert("foo", "bar");
29 params.insert("baz", "quux");
30
31 let res = from_hashmap(¶ms).unwrap();
32 print!("{res}");
33 }
35}