xavier_internal/serialize/
collections.rs1use std::collections::HashMap;
2use crate::serialize::macro_trait::XmlSerializable;
3
4impl <T: XmlSerializable> XmlSerializable for Vec<T> {
5 fn to_xml(&self, tag_name: Option<&str>, _: bool) -> String {
6 self.iter().fold(String::new(), |mut acc, item| {
7 acc.push_str(&item.to_xml(tag_name,false));
8 acc
9 })
10 }
11}
12
13impl <T: XmlSerializable> XmlSerializable for HashMap<String, T> {
14 fn to_xml(&self, tag_name: Option<&str>, _: bool) -> String {
15 self.iter().fold(String::new(), |mut acc, item| {
16 acc.push_str(&format!("<{}>", &item.0));
17 acc.push_str(&item.1.to_xml(tag_name,false));
18 acc.push_str(&format!("</{}>", &item.0));
19 acc
20 })
21 }
22}