diff --git a/src/delay.rs b/src/delay.rs index b96db2bd..e5123ec2 100644 --- a/src/delay.rs +++ b/src/delay.rs @@ -49,7 +49,7 @@ impl From for Element { fn from(delay: Delay) -> Element { Element::builder("delay") .ns(ns::DELAY) - .attr("from", delay.from.and_then(|value| Some(String::from(value)))) + .attr("from", delay.from.map(String::from)) .attr("stamp", delay.stamp.to_rfc3339()) .append(delay.data) .build() diff --git a/src/iq.rs b/src/iq.rs index aab1efcb..1eae2549 100644 --- a/src/iq.rs +++ b/src/iq.rs @@ -272,8 +272,8 @@ impl From for Element { fn from(iq: Iq) -> Element { let mut stanza = Element::builder("iq") .ns(ns::JABBER_CLIENT) - .attr("from", iq.from.and_then(|value| Some(String::from(value)))) - .attr("to", iq.to.and_then(|value| Some(String::from(value)))) + .attr("from", iq.from.map(String::from)) + .attr("to", iq.to.map(String::from)) .attr("id", iq.id) .attr("type", &iq.payload) .build(); diff --git a/src/message.rs b/src/message.rs index ea560425..29234321 100644 --- a/src/message.rs +++ b/src/message.rs @@ -204,8 +204,8 @@ impl From for Element { fn from(message: Message) -> Element { Element::builder("message") .ns(ns::JABBER_CLIENT) - .attr("from", message.from.and_then(|value| Some(String::from(value)))) - .attr("to", message.to.and_then(|value| Some(String::from(value)))) + .attr("from", message.from.map(String::from)) + .attr("to", message.to.map(String::from)) .attr("id", message.id) .attr("type", message.type_) .append(message.subjects.into_iter() diff --git a/src/presence.rs b/src/presence.rs index fe970e3b..93c5cf94 100644 --- a/src/presence.rs +++ b/src/presence.rs @@ -317,8 +317,8 @@ impl From for Element { fn from(presence: Presence) -> Element { Element::builder("presence") .ns(ns::JABBER_CLIENT) - .attr("from", presence.from.and_then(|value| Some(String::from(value)))) - .attr("to", presence.to.and_then(|value| Some(String::from(value)))) + .attr("from", presence.from.map(String::from)) + .attr("to", presence.to.map(String::from)) .attr("id", presence.id) .attr("type", presence.type_) .append(presence.show) diff --git a/src/pubsub/event.rs b/src/pubsub/event.rs index ef5e994b..04519e96 100644 --- a/src/pubsub/event.rs +++ b/src/pubsub/event.rs @@ -31,7 +31,7 @@ impl From for Element { .ns(ns::PUBSUB_EVENT) .attr("id", item.id) .attr("node", item.node) - .attr("publisher", item.publisher.and_then(|publisher| Some(String::from(publisher)))) + .attr("publisher", item.publisher.map(String::from)) .append(item.payload) .build() } @@ -222,11 +222,11 @@ impl From for Element { Element::builder("purge") .ns(ns::PUBSUB_EVENT) .attr("node", node) - .append(redirect.and_then(|redirect| { - Some(Element::builder("redirect") - .ns(ns::PUBSUB_EVENT) - .attr("uri", redirect) - .build()) + .append(redirect.map(|redirect| { + Element::builder("redirect") + .ns(ns::PUBSUB_EVENT) + .attr("uri", redirect) + .build() })) .build() }, @@ -260,8 +260,8 @@ impl From for Element { Element::builder("subscription") .ns(ns::PUBSUB_EVENT) .attr("node", node) - .attr("expiry", expiry.and_then(|expiry| Some(expiry.to_rfc3339()))) - .attr("jid", jid.and_then(|jid| Some(String::from(jid)))) + .attr("expiry", expiry.map(|expiry| expiry.to_rfc3339())) + .attr("jid", jid.map(String::from)) .attr("subid", subid) .attr("subscription", subscription) .build() diff --git a/src/stanza_error.rs b/src/stanza_error.rs index 4a83b8dc..3b7273b3 100644 --- a/src/stanza_error.rs +++ b/src/stanza_error.rs @@ -177,7 +177,7 @@ impl From for Element { let mut root = Element::builder("error") .ns(ns::JABBER_CLIENT) .attr("type", err.type_) - .attr("by", err.by.and_then(|by| Some(String::from(by)))) + .attr("by", err.by.map(String::from)) .append(err.defined_condition) .build(); for (lang, text) in err.texts {