From b4e47e9a78136be5404e5e307a28d9c0d43cc90b Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 25 May 2017 00:41:13 +0100 Subject: [PATCH] mam: Improve serialisation. --- src/mam.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/mam.rs b/src/mam.rs index 22ec057..c8cd2ac 100644 --- a/src/mam.rs +++ b/src/mam.rs @@ -188,18 +188,13 @@ impl TryFrom for Prefs { impl Into for Query { fn into(self) -> Element { - let mut elem = Element::builder("query") - .ns(ns::MAM) - .attr("queryid", self.queryid.clone()) - .attr("node", self.node.clone()) - .build(); - //if let Some(form) = self.form { - // elem.append_child(form.into()); - //} - if let Some(set) = self.set { - elem.append_child(set.into()); - } - elem + Element::builder("query") + .ns(ns::MAM) + .attr("queryid", self.queryid) + .attr("node", self.node) + //.append(self.form.map(|form| -> Element { form.into() })) + .append(self.set.map(|set| -> Element { set.into() })) + .build() } } @@ -236,7 +231,7 @@ impl Into for Prefs { let mut always = Element::builder("always") .ns(ns::RSM) .build(); - for jid in self.always.clone() { + for jid in self.always { always.append_child(Element::builder("jid") .ns(ns::RSM) .append(String::from(jid)) @@ -248,7 +243,7 @@ impl Into for Prefs { let mut never = Element::builder("never") .ns(ns::RSM) .build(); - for jid in self.never.clone() { + for jid in self.never { never.append_child(Element::builder("jid") .ns(ns::RSM) .append(String::from(jid))