This commit is contained in:
Candifloss 2024-10-17 16:46:01 +05:30
parent e71891343c
commit 28c808f07f

View File

@ -22,19 +22,21 @@ where
pub fn serialize_hints<S>( pub fn serialize_hints<S>(
hints: &HashMap<String, OwnedValue>, hints: &HashMap<String, OwnedValue>,
serializer: Serializer, serializer: S,
) -> Result<S::Ok, S::Error> { ) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut hint_map = serde_json::Map::new(); let mut hint_map = serde_json::Map::new();
for hint in hints { for hint in hints {
if let (hint_name, hint_val) = hint { let (hint_name, hint_val) = hint;
let mut h = serde_json::Map::new(); let mut h = serde_json::Map::new();
let sig = hint_val.value_signature(); let sig = hint_val.value_signature();
let val = hint_val.try_clone(); let val = hint_val.try_clone();
h.insert(sig.to_string(), serde_json::Value::String(val)); h.insert(sig.to_string(), serde_json::Value::String(val));
hint_map.insert(hint_name.clone(), serde_json::Value::Object(h.clone())); hint_map.insert(hint_name.clone(), serde_json::Value::Object(h.clone()));
}
} }
hint_map.serialize(serializer) hint_map.serialize(serializer)