diff --git a/src/internal_macros.rs b/src/internal_macros.rs index 6baae6b8..873ae88f 100644 --- a/src/internal_macros.rs +++ b/src/internal_macros.rs @@ -20,7 +20,7 @@ macro_rules! impl_consensus_encoding { ($thing:ident, $($field:ident),+) => ( impl $crate::consensus::Encodable for $thing { #[inline] - fn consensus_encode( + fn consensus_encode( &self, mut s: S, ) -> Result { @@ -32,7 +32,7 @@ macro_rules! impl_consensus_encoding { impl $crate::consensus::Decodable for $thing { #[inline] - fn consensus_decode( + fn consensus_decode( mut d: D, ) -> Result<$thing, $crate::consensus::encode::Error> { Ok($thing { @@ -82,7 +82,7 @@ macro_rules! impl_array_newtype { pub fn into_bytes(self) -> [$ty; $len] { self.0 } } - impl<'a> $crate::std::convert::From<&'a [$ty]> for $thing { + impl<'a> ::std::convert::From<&'a [$ty]> for $thing { fn from(data: &'a [$ty]) -> $thing { assert_eq!(data.len(), $len); let mut ret = [0; $len]; @@ -91,7 +91,7 @@ macro_rules! impl_array_newtype { } } - impl $crate::std::ops::Index for $thing { + impl ::std::ops::Index for $thing { type Output = $ty; #[inline] @@ -103,57 +103,57 @@ macro_rules! impl_array_newtype { impl_index_newtype!($thing, $ty); - impl $crate::std::cmp::PartialEq for $thing { + impl ::std::cmp::PartialEq for $thing { #[inline] fn eq(&self, other: &$thing) -> bool { &self[..] == &other[..] } } - impl $crate::std::cmp::Eq for $thing {} + impl ::std::cmp::Eq for $thing {} - impl $crate::std::cmp::PartialOrd for $thing { + impl ::std::cmp::PartialOrd for $thing { #[inline] - fn partial_cmp(&self, other: &$thing) -> Option<$crate::std::cmp::Ordering> { + fn partial_cmp(&self, other: &$thing) -> Option<::std::cmp::Ordering> { Some(self.cmp(&other)) } } - impl $crate::std::cmp::Ord for $thing { + impl ::std::cmp::Ord for $thing { #[inline] - fn cmp(&self, other: &$thing) -> $crate::std::cmp::Ordering { + fn cmp(&self, other: &$thing) -> ::std::cmp::Ordering { // manually implement comparison to get little-endian ordering // (we need this for our numeric types; non-numeric ones shouldn't // be ordered anyway except to put them in BTrees or whatever, and // they don't care how we order as long as we're consistent). for i in 0..$len { - if self[$len - 1 - i] < other[$len - 1 - i] { return $crate::std::cmp::Ordering::Less; } - if self[$len - 1 - i] > other[$len - 1 - i] { return $crate::std::cmp::Ordering::Greater; } + if self[$len - 1 - i] < other[$len - 1 - i] { return ::std::cmp::Ordering::Less; } + if self[$len - 1 - i] > other[$len - 1 - i] { return ::std::cmp::Ordering::Greater; } } - $crate::std::cmp::Ordering::Equal + ::std::cmp::Ordering::Equal } } #[cfg_attr(feature = "clippy", allow(expl_impl_clone_on_copy))] // we don't define the `struct`, we have to explicitly impl - impl $crate::std::clone::Clone for $thing { + impl ::std::clone::Clone for $thing { #[inline] fn clone(&self) -> $thing { $thing::from(&self[..]) } } - impl $crate::std::marker::Copy for $thing {} + impl ::std::marker::Copy for $thing {} - impl $crate::std::hash::Hash for $thing { + impl ::std::hash::Hash for $thing { #[inline] fn hash(&self, state: &mut H) - where H: $crate::std::hash::Hasher + where H: ::std::hash::Hasher { (&self[..]).hash(state); } fn hash_slice(data: &[$thing], state: &mut H) - where H: $crate::std::hash::Hasher + where H: ::std::hash::Hasher { for d in data.iter() { (&d[..]).hash(state); @@ -166,8 +166,8 @@ macro_rules! impl_array_newtype { /// Implements debug formatting for a given wrapper type macro_rules! impl_array_newtype_show { ($thing:ident) => { - impl $crate::std::fmt::Debug for $thing { - fn fmt(&self, f: &mut $crate::std::fmt::Formatter) -> $crate::std::fmt::Result { + impl ::std::fmt::Debug for $thing { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { write!(f, concat!(stringify!($thing), "({:?})"), &self[..]) } } @@ -177,38 +177,38 @@ macro_rules! impl_array_newtype_show { /// Implements standard indexing methods for a given wrapper type macro_rules! impl_index_newtype { ($thing:ident, $ty:ty) => { - impl $crate::std::ops::Index<$crate::std::ops::Range> for $thing { + impl ::std::ops::Index<::std::ops::Range> for $thing { type Output = [$ty]; #[inline] - fn index(&self, index: $crate::std::ops::Range) -> &[$ty] { + fn index(&self, index: ::std::ops::Range) -> &[$ty] { &self.0[index] } } - impl $crate::std::ops::Index<$crate::std::ops::RangeTo> for $thing { + impl ::std::ops::Index<::std::ops::RangeTo> for $thing { type Output = [$ty]; #[inline] - fn index(&self, index: $crate::std::ops::RangeTo) -> &[$ty] { + fn index(&self, index: ::std::ops::RangeTo) -> &[$ty] { &self.0[index] } } - impl $crate::std::ops::Index<$crate::std::ops::RangeFrom> for $thing { + impl ::std::ops::Index<::std::ops::RangeFrom> for $thing { type Output = [$ty]; #[inline] - fn index(&self, index: $crate::std::ops::RangeFrom) -> &[$ty] { + fn index(&self, index: ::std::ops::RangeFrom) -> &[$ty] { &self.0[index] } } - impl $crate::std::ops::Index<$crate::std::ops::RangeFull> for $thing { + impl ::std::ops::Index<::std::ops::RangeFull> for $thing { type Output = [$ty]; #[inline] - fn index(&self, _: $crate::std::ops::RangeFull) -> &[$ty] { + fn index(&self, _: ::std::ops::RangeFull) -> &[$ty] { &self.0[..] } } @@ -218,9 +218,9 @@ macro_rules! impl_index_newtype { macro_rules! display_from_debug { ($thing:ident) => { - impl $crate::std::fmt::Display for $thing { - fn fmt(&self, f: &mut $crate::std::fmt::Formatter) -> Result<(), $crate::std::fmt::Error> { - $crate::std::fmt::Debug::fmt(self, f) + impl ::std::fmt::Display for $thing { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(self, f) } } } @@ -240,7 +240,7 @@ macro_rules! serde_struct_impl { where D: $crate::serde::de::Deserializer<'de>, { - use $crate::std::fmt::{self, Formatter}; + use ::std::fmt::{self, Formatter}; use $crate::serde::de::IgnoredAny; #[allow(non_camel_case_types)] @@ -382,8 +382,8 @@ macro_rules! serde_string_impl { where D: $crate::serde::de::Deserializer<'de>, { - use $crate::std::fmt::{self, Formatter}; - use $crate::std::str::FromStr; + use ::std::fmt::{self, Formatter}; + use ::std::str::FromStr; struct Visitor; impl<'de> $crate::serde::de::Visitor<'de> for Visitor { @@ -443,8 +443,8 @@ macro_rules! serde_struct_human_string_impl { D: $crate::serde::de::Deserializer<'de>, { if deserializer.is_human_readable() { - use $crate::std::fmt::{self, Formatter}; - use $crate::std::str::FromStr; + use ::std::fmt::{self, Formatter}; + use ::std::str::FromStr; struct Visitor; impl<'de> $crate::serde::de::Visitor<'de> for Visitor { @@ -478,7 +478,7 @@ macro_rules! serde_struct_human_string_impl { deserializer.deserialize_str(Visitor) } else { - use $crate::std::fmt::{self, Formatter}; + use ::std::fmt::{self, Formatter}; use $crate::serde::de::IgnoredAny; #[allow(non_camel_case_types)] @@ -626,8 +626,8 @@ macro_rules! serde_struct_human_string_impl { macro_rules! impl_bytes_newtype { ($t:ident, $len:expr) => ( - impl $crate::std::fmt::LowerHex for $t { - fn fmt(&self, f: &mut $crate::std::fmt::Formatter) -> $crate::std::fmt::Result { + impl ::std::fmt::LowerHex for $t { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { for &ch in self.0.iter() { write!(f, "{:02x}", ch)?; } @@ -635,17 +635,17 @@ macro_rules! impl_bytes_newtype { } } - impl $crate::std::fmt::Display for $t { - fn fmt(&self, f: &mut $crate::std::fmt::Formatter) -> $crate::std::fmt::Result { + impl ::std::fmt::Display for $t { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt::LowerHex::fmt(self, f) } } impl $crate::hashes::hex::FromHex for $t { fn from_byte_iter(iter: I) -> Result - where I: $crate::std::iter::Iterator> + - $crate::std::iter::ExactSizeIterator + - $crate::std::iter::DoubleEndedIterator, + where I: ::std::iter::Iterator> + + ::std::iter::ExactSizeIterator + + ::std::iter::DoubleEndedIterator, { if iter.len() == $len { let mut ret = [0; $len]; @@ -659,7 +659,7 @@ macro_rules! impl_bytes_newtype { } } - impl $crate::std::str::FromStr for $t { + impl ::std::str::FromStr for $t { type Err = $crate::hashes::hex::Error; fn from_str(s: &str) -> Result { $crate::hashes::hex::FromHex::from_hex(s) @@ -686,7 +686,7 @@ macro_rules! impl_bytes_newtype { impl<'de> $crate::serde::de::Visitor<'de> for HexVisitor { type Value = $t; - fn expecting(&self, formatter: &mut $crate::std::fmt::Formatter) -> $crate::std::fmt::Result { + fn expecting(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { formatter.write_str("an ASCII hex string") } @@ -694,7 +694,7 @@ macro_rules! impl_bytes_newtype { where E: $crate::serde::de::Error, { - if let Ok(hex) = $crate::std::str::from_utf8(v) { + if let Ok(hex) = ::std::str::from_utf8(v) { $crate::hashes::hex::FromHex::from_hex(hex).map_err(E::custom) } else { return Err(E::invalid_value($crate::serde::de::Unexpected::Bytes(v), &self)); @@ -716,7 +716,7 @@ macro_rules! impl_bytes_newtype { impl<'de> $crate::serde::de::Visitor<'de> for BytesVisitor { type Value = $t; - fn expecting(&self, formatter: &mut $crate::std::fmt::Formatter) -> $crate::std::fmt::Result { + fn expecting(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { formatter.write_str("a bytestring") } @@ -754,30 +754,30 @@ macro_rules! user_enum { $(#[$doc] $elem),* } - impl $crate::std::fmt::Debug for $name { - fn fmt(&self, f: &mut $crate::std::fmt::Formatter) -> $crate::std::fmt::Result { + impl ::std::fmt::Debug for $name { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { f.pad(match *self { $($name::$elem => $txt),* }) } } - impl $crate::std::fmt::Display for $name { - fn fmt(&self, f: &mut $crate::std::fmt::Formatter) -> $crate::std::fmt::Result { + impl ::std::fmt::Display for $name { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { f.pad(match *self { $($name::$elem => $txt),* }) } } - impl $crate::std::str::FromStr for $name { - type Err = $crate::std::io::Error; + impl ::std::str::FromStr for $name { + type Err = ::std::io::Error; #[inline] fn from_str(s: &str) -> Result { match s { $($txt => Ok($name::$elem)),*, - _ => Err($crate::std::io::Error::new( - $crate::std::io::ErrorKind::InvalidInput, + _ => Err(::std::io::Error::new( + ::std::io::ErrorKind::InvalidInput, format!("Unknown network (type {})", s), )), } @@ -791,7 +791,7 @@ macro_rules! user_enum { where D: $crate::serde::Deserializer<'de>, { - use $crate::std::fmt::{self, Formatter}; + use ::std::fmt::{self, Formatter}; struct Visitor; impl<'de> $crate::serde::de::Visitor<'de> for Visitor { diff --git a/src/util/psbt/macros.rs b/src/util/psbt/macros.rs index 43970504..9c3bcab0 100644 --- a/src/util/psbt/macros.rs +++ b/src/util/psbt/macros.rs @@ -55,7 +55,7 @@ macro_rules! impl_psbt_serialize { macro_rules! impl_psbtmap_consensus_encoding { ($thing:ty) => { impl $crate::consensus::Encodable for $thing { - fn consensus_encode( + fn consensus_encode( &self, mut s: S, ) -> Result { @@ -76,10 +76,10 @@ macro_rules! impl_psbtmap_consensus_encoding { macro_rules! impl_psbtmap_consensus_decoding { ($thing:ty) => { impl $crate::consensus::Decodable for $thing { - fn consensus_decode( + fn consensus_decode( mut d: D, ) -> Result { - let mut rv: Self = $crate::std::default::Default::default(); + let mut rv: Self = ::std::default::Default::default(); loop { match $crate::consensus::Decodable::consensus_decode(&mut d) {