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 da2e6f64..9a7ed98c 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 6858c114..83ac6f55 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 0f42e50a..a93fc40b 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 6904ca83..8aba744e 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 5d6e7111..9016123f 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 e414b91a..47843cea 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 d7717a7b..2c0497cc 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 e4b09924..f2831ea1 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 632540ed..dca42668 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 8fd05770..5ea49210 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 db91c44f..b3e1aa57 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 26cdcf99..bfd33b86 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 c83915be..80f3147a 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 fa696d08..615580df 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 470a4647..e9ec8326 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 cb78e4ef..358e4a46 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 a0ab15bb..cb192804 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 6e65e012..3fbcfae8 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 83335ae2..168eee1f 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 163ce3ef..e98d278d 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() {