From 292cdd059c0177cebad8f8e16d4392bf99319882 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Mon, 14 May 2018 16:07:15 +0200 Subject: [PATCH] macros: Remove use requirement on try_from::TryFrom. --- src/attention.rs | 3 +-- src/chatstates.rs | 3 +-- src/component.rs | 3 +-- src/delay.rs | 3 +-- src/eme.rs | 3 +-- src/hashes.rs | 2 +- src/ibb.rs | 2 +- src/idle.rs | 3 +-- src/jingle_ibb.rs | 2 +- src/macros.rs | 14 +++++++------- src/media_element.rs | 3 +-- src/message_correct.rs | 3 +-- src/mood.rs | 3 +-- src/ping.rs | 3 +-- src/receipts.rs | 3 +-- src/roster.rs | 2 +- src/sasl.rs | 2 +- src/stanza_id.rs | 3 +-- src/stream.rs | 3 +-- src/websocket.rs | 3 +-- 20 files changed, 26 insertions(+), 40 deletions(-) diff --git a/src/attention.rs b/src/attention.rs index da2e6f6494becee18aba3bea136b8e46cf9b19a8..9a7ed98c618124fd9e0688d0a6187cae15b5cb24 100644 --- a/src/attention.rs +++ b/src/attention.rs @@ -4,8 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; - use minidom::Element; use error::Error; @@ -17,6 +15,7 @@ generate_empty_element!(Attention, "attention", ns::ATTENTION); #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; #[test] fn test_simple() { diff --git a/src/chatstates.rs b/src/chatstates.rs index 6858c1147a012896e0afe467e7d31beabcd1c814..83ac6f55b5b6973270429381e65802b24f7e2937 100644 --- a/src/chatstates.rs +++ b/src/chatstates.rs @@ -6,8 +6,6 @@ #![deny(missing_docs)] -use try_from::TryFrom; - use minidom::Element; use error::Error; @@ -38,6 +36,7 @@ generate_element_enum!( #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; #[test] fn test_simple() { diff --git a/src/component.rs b/src/component.rs index 0f42e50ae67b08872579cb0554f7f0a1b66ec594..a93fc40ba9bfdbbca5453aa86ef4ea0c39020f33 100644 --- a/src/component.rs +++ b/src/component.rs @@ -4,8 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; - use minidom::Element; use error::Error; use helpers::PlainText; @@ -38,6 +36,7 @@ impl Handshake { #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; #[test] fn test_simple() { diff --git a/src/delay.rs b/src/delay.rs index 6904ca838edc35b415f8ad6218d16f9887476b7b..8aba744ee5ce46b11a9c41e7919f63724cb06813 100644 --- a/src/delay.rs +++ b/src/delay.rs @@ -4,8 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; - use minidom::Element; use date::DateTime; @@ -26,6 +24,7 @@ generate_element_with_text!(Delay, "delay", ns::DELAY, #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; use std::str::FromStr; #[test] diff --git a/src/eme.rs b/src/eme.rs index 5d6e7111ffabfd5060d2b752dd75a65df6ce78e8..9016123f8a5aee0e1e8a4d8fdfa57eb765dd2120 100644 --- a/src/eme.rs +++ b/src/eme.rs @@ -4,8 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; - use minidom::Element; use error::Error; @@ -26,6 +24,7 @@ ExplicitMessageEncryption, "encryption", ns::EME, [ #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; #[test] fn test_simple() { diff --git a/src/hashes.rs b/src/hashes.rs index e414b91a4fb100ac86a172553810af0fbe27865f..47843cea1ef89fba99c482780704a536aa02f007 100644 --- a/src/hashes.rs +++ b/src/hashes.rs @@ -4,7 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; use std::str::FromStr; use minidom::{Element, IntoAttributeValue}; @@ -93,6 +92,7 @@ impl Hash { #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; #[test] fn test_simple() { diff --git a/src/ibb.rs b/src/ibb.rs index d7717a7b7105cc23258c0d0f36faec4af7b4b089..2c0497cc7b32d6ec82729d403e18577575655ede 100644 --- a/src/ibb.rs +++ b/src/ibb.rs @@ -4,7 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; use std::str::FromStr; use minidom::{Element, IntoAttributeValue}; @@ -40,6 +39,7 @@ generate_element_with_only_attributes!(Close, "close", ns::IBB, [ #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; use std::error::Error as StdError; #[test] diff --git a/src/idle.rs b/src/idle.rs index e4b09924580777f39746e0d25a743a24279fdfb0..f2831ea1813c18909016c244a5c6504b91fef201 100644 --- a/src/idle.rs +++ b/src/idle.rs @@ -4,8 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; - use minidom::Element; use date::DateTime; @@ -20,6 +18,7 @@ generate_element_with_only_attributes!(Idle, "idle", ns::IDLE, [ #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; use std::str::FromStr; use std::error::Error as StdError; diff --git a/src/jingle_ibb.rs b/src/jingle_ibb.rs index 632540ed2cc909d22c3625a5e621a1c6565ab498..dca426681a0852258fa6f559ca1ddc91e0fb9f2d 100644 --- a/src/jingle_ibb.rs +++ b/src/jingle_ibb.rs @@ -4,7 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; use std::str::FromStr; use minidom::{Element, IntoAttributeValue}; @@ -26,6 +25,7 @@ generate_element_with_only_attributes!(Transport, "transport", ns::JINGLE_IBB, [ #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; use std::error::Error as StdError; #[test] diff --git a/src/macros.rs b/src/macros.rs index 8fd057705355898475fdba3e6995e21b926b66e4..5ea49210ed35ff48214f0e0b733e4a97fcec6015 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -116,7 +116,7 @@ macro_rules! generate_element_enum { $enum ),+ } - impl TryFrom for $elem { + impl ::try_from::TryFrom for $elem { type Err = Error; fn try_from(elem: Element) -> Result<$elem, Error> { check_ns_only!(elem, $name, $ns); @@ -152,7 +152,7 @@ macro_rules! generate_attribute_enum { $enum ),+ } - impl TryFrom for $elem { + impl ::try_from::TryFrom for $elem { type Err = Error; fn try_from(elem: Element) -> Result<$elem, Error> { check_ns_only!(elem, $name, $ns); @@ -231,7 +231,7 @@ macro_rules! generate_empty_element { #[derive(Debug, Clone)] pub struct $elem; - impl TryFrom for $elem { + impl ::try_from::TryFrom for $elem { type Err = Error; fn try_from(elem: Element) -> Result<$elem, Error> { @@ -266,7 +266,7 @@ macro_rules! generate_element_with_only_attributes { )* } - impl TryFrom for $elem { + impl ::try_from::TryFrom for $elem { type Err = Error; fn try_from(elem: Element) -> Result<$elem, Error> { @@ -324,7 +324,7 @@ macro_rules! generate_elem_id { Ok($elem(String::from(s))) } } - impl TryFrom for $elem { + impl ::try_from::TryFrom for $elem { type Err = Error; fn try_from(elem: Element) -> Result<$elem, Error> { check_self!(elem, $name, $ns); @@ -360,7 +360,7 @@ macro_rules! generate_element_with_text { pub $text_ident: $text_type, } - impl TryFrom for $elem { + impl ::try_from::TryFrom for $elem { type Err = Error; fn try_from(elem: Element) -> Result<$elem, Error> { @@ -405,7 +405,7 @@ macro_rules! generate_element_with_children { )* } - impl TryFrom for $elem { + impl ::try_from::TryFrom for $elem { type Err = Error; fn try_from(elem: Element) -> Result<$elem, Error> { diff --git a/src/media_element.rs b/src/media_element.rs index db91c44f44128c6d20bf0b5a9f47929f61486c74..b3e1aa5716c06dabc1c22cd7e8b00ad522de2014 100644 --- a/src/media_element.rs +++ b/src/media_element.rs @@ -4,8 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; - use minidom::Element; use error::Error; @@ -33,6 +31,7 @@ generate_element_with_children!(MediaElement, "media", ns::MEDIA_ELEMENT, #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; use data_forms::DataForm; use std::error::Error as StdError; diff --git a/src/message_correct.rs b/src/message_correct.rs index 26cdcf99596b8c79d8403dabbe108f46e8800d02..bfd33b86bd877c31948a789ebcf36c760a0882f0 100644 --- a/src/message_correct.rs +++ b/src/message_correct.rs @@ -4,8 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; - use minidom::Element; use error::Error; @@ -19,6 +17,7 @@ generate_element_with_only_attributes!(Replace, "replace", ns::MESSAGE_CORRECT, #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; #[test] fn test_simple() { diff --git a/src/mood.rs b/src/mood.rs index c83915be62d0d68c595c3352c76bf4bcc802f73d..80f3147a18c18c7e7a840295ac85532e7d8f97d0 100644 --- a/src/mood.rs +++ b/src/mood.rs @@ -6,8 +6,6 @@ #![deny(missing_docs)] -use try_from::TryFrom; - use minidom::Element; use error::Error; @@ -274,6 +272,7 @@ generate_element_enum!( #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; #[test] fn test_simple() { diff --git a/src/ping.rs b/src/ping.rs index fa696d08bbc472cff36cc40a83d83eb98f3af2d7..615580dfd548e98fe5b3505ac8428874e995b348 100644 --- a/src/ping.rs +++ b/src/ping.rs @@ -5,8 +5,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; - use minidom::Element; use error::Error; @@ -18,6 +16,7 @@ generate_empty_element!(Ping, "ping", ns::PING); #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; #[test] fn test_simple() { diff --git a/src/receipts.rs b/src/receipts.rs index 470a46474dde9241e8fc74570fa186429aa0ace9..e9ec83265692f389285b5d8eaf6998e7c0da4d56 100644 --- a/src/receipts.rs +++ b/src/receipts.rs @@ -4,8 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; - use minidom::Element; use error::Error; @@ -21,6 +19,7 @@ generate_element_with_only_attributes!(Received, "received", ns::RECEIPTS, [ #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; #[test] fn test_simple() { diff --git a/src/roster.rs b/src/roster.rs index cb78e4ef5a2f1c60f5b00bba931b913ecd9fdc44..358e4a461c47e5336007cc645b3ee19b331e5cb9 100644 --- a/src/roster.rs +++ b/src/roster.rs @@ -4,7 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; use std::str::FromStr; use minidom::{Element, IntoAttributeValue}; @@ -64,6 +63,7 @@ generate_element_with_children!( #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; use compare_elements::NamespaceAwareCompare; #[test] diff --git a/src/sasl.rs b/src/sasl.rs index a0ab15bb7d12c3c7edabaee59f9f289d4a8f6df5..cb192804f094380d2734ff88ae4bd0d96f10e00a 100644 --- a/src/sasl.rs +++ b/src/sasl.rs @@ -4,7 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; use std::str::FromStr; use minidom::{Element, IntoAttributeValue}; @@ -42,6 +41,7 @@ generate_element_with_text!(Success, "success", ns::SASL, #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; #[test] fn test_simple() { diff --git a/src/stanza_id.rs b/src/stanza_id.rs index 6e65e012b885d13e0b1458b3687f710743a21746..3fbcfae857e19be0bf17d99f078f7e595762125a 100644 --- a/src/stanza_id.rs +++ b/src/stanza_id.rs @@ -4,8 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; - use minidom::Element; use jid::Jid; @@ -25,6 +23,7 @@ generate_element_with_only_attributes!(OriginId, "origin-id", ns::SID, [ #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; use std::str::FromStr; #[test] diff --git a/src/stream.rs b/src/stream.rs index 83335ae2377aa3fd51670595d56a274b4937ac46..168eee1fc25f5d34cd112d8caa9544f6487ef7dc 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -4,8 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; - use minidom::Element; use jid::Jid; use error::Error; @@ -56,6 +54,7 @@ impl Stream { #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; #[test] fn test_simple() { diff --git a/src/websocket.rs b/src/websocket.rs index 163ce3ef4ae91b2699a90b60c1d069f7df470584..e98d278dcaf978fd8fb825f9e90e88fe17fbe851 100644 --- a/src/websocket.rs +++ b/src/websocket.rs @@ -4,8 +4,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use try_from::TryFrom; - use minidom::Element; use jid::Jid; use error::Error; @@ -56,6 +54,7 @@ impl Open { #[cfg(test)] mod tests { use super::*; + use try_from::TryFrom; #[test] fn test_simple() {