diff --git a/src/blockdata/script.rs b/src/blockdata/script.rs index 0f29265e..8ae8e525 100644 --- a/src/blockdata/script.rs +++ b/src/blockdata/script.rs @@ -112,7 +112,7 @@ impl hex::FromHex for Script { } } -impl ::core::str::FromStr for Script { +impl core::str::FromStr for Script { type Err = hex::Error; fn from_str(s: &str) -> Result { hex::FromHex::from_hex(s) @@ -303,7 +303,7 @@ pub fn read_uint(data: &[u8], size: usize) -> Result { // We internally use implementation based on iterator so that it automatically advances as needed // Errors are same as above, just different type. -fn read_uint_iter(data: &mut ::core::slice::Iter<'_, u8>, size: usize) -> Result { +fn read_uint_iter(data: &mut core::slice::Iter<'_, u8>, size: usize) -> Result { if data.len() < size { Err(UintError::EarlyEndOfScript) } else if size > usize::from(u16::max_value() / 8) { @@ -626,7 +626,7 @@ impl Script { #[cfg(feature="bitcoinconsensus")] #[cfg_attr(docsrs, doc(cfg(feature = "bitcoinconsensus")))] pub fn verify (&self, index: usize, amount: crate::Amount, spending: &[u8]) -> Result<(), Error> { - self.verify_with_flags(index, amount, spending, ::bitcoinconsensus::VERIFY_ALL) + self.verify_with_flags(index, amount, spending, bitcoinconsensus::VERIFY_ALL) } /// Verifies spend of an input script. @@ -756,7 +756,7 @@ pub enum Instruction<'a> { /// Iterator over a script returning parsed opcodes. pub struct Instructions<'a> { - data: ::core::slice::Iter<'a, u8>, + data: core::slice::Iter<'a, u8>, enforce_minimal: bool, } @@ -852,7 +852,7 @@ impl<'a> Iterator for Instructions<'a> { } } -impl<'a> ::core::iter::FusedIterator for Instructions<'a> {} +impl<'a> core::iter::FusedIterator for Instructions<'a> {} impl Builder { /// Creates a new empty script. @@ -1490,14 +1490,14 @@ mod test { let script = Script::from(vec![0u8, 1u8, 2u8]); // Serialize - let json = ::serde_json::to_string(&script).unwrap(); + let json = serde_json::to_string(&script).unwrap(); assert_eq!(json, "\"000102\""); - let bincode = ::bincode::serialize(&script).unwrap(); + let bincode = bincode::serialize(&script).unwrap(); assert_eq!(bincode, [3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2]); // bincode adds u64 for length, serde_cbor use varint // Deserialize - assert_eq!(script, ::serde_json::from_str(&json).unwrap()); - assert_eq!(script, ::bincode::deserialize(&bincode).unwrap()); + assert_eq!(script, serde_json::from_str(&json).unwrap()); + assert_eq!(script, bincode::deserialize(&bincode).unwrap()); } #[test] diff --git a/src/blockdata/transaction.rs b/src/blockdata/transaction.rs index 3314cba1..59b916b8 100644 --- a/src/blockdata/transaction.rs +++ b/src/blockdata/transaction.rs @@ -152,7 +152,7 @@ fn parse_vout(s: &str) -> Result { s.parse().map_err(ParseOutPointError::Vout) } -impl ::core::str::FromStr for OutPoint { +impl core::str::FromStr for OutPoint { type Err = ParseOutPointError; fn from_str(s: &str) -> Result { @@ -880,7 +880,7 @@ impl Transaction { where S: FnMut(&OutPoint) -> Option { - self.verify_with_flags(spent, ::bitcoinconsensus::VERIFY_ALL) + self.verify_with_flags(spent, bitcoinconsensus::VERIFY_ALL) } /// Verify that this transaction is able to spend its inputs. diff --git a/src/internal_macros.rs b/src/internal_macros.rs index 5f4f5d5b..1a8c58f3 100644 --- a/src/internal_macros.rs +++ b/src/internal_macros.rs @@ -110,15 +110,15 @@ macro_rules! impl_array_newtype { macro_rules! display_from_debug { ($thing:ident) => { impl core::fmt::Display for $thing { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> Result<(), ::core::fmt::Error> { - ::core::fmt::Debug::fmt(self, f) + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + core::fmt::Debug::fmt(self, f) } } } } #[cfg(test)] -macro_rules! hex_script (($s:expr) => (<$crate::Script as ::core::str::FromStr>::from_str($s).unwrap())); +macro_rules! hex_script (($s:expr) => (<$crate::Script as core::str::FromStr>::from_str($s).unwrap())); #[cfg(test)] macro_rules! hex_hash (($h:ident, $s:expr) => ($h::from_slice(&<$crate::prelude::Vec as $crate::hashes::hex::FromHex>::from_hex($s).unwrap()).unwrap())); @@ -135,8 +135,8 @@ macro_rules! serde_string_impl { where D: $crate::serde::de::Deserializer<'de>, { - use ::core::fmt::{self, Formatter}; - use ::core::str::FromStr; + use core::fmt::{self, Formatter}; + use core::str::FromStr; struct Visitor; impl<'de> $crate::serde::de::Visitor<'de> for Visitor { @@ -183,8 +183,8 @@ macro_rules! serde_struct_human_string_impl { D: $crate::serde::de::Deserializer<'de>, { if deserializer.is_human_readable() { - use ::core::fmt::{self, Formatter}; - use ::core::str::FromStr; + use core::fmt::{self, Formatter}; + use core::str::FromStr; struct Visitor; impl<'de> $crate::serde::de::Visitor<'de> for Visitor { @@ -205,7 +205,7 @@ macro_rules! serde_struct_human_string_impl { deserializer.deserialize_str(Visitor) } else { - use ::core::fmt::{self, Formatter}; + use core::fmt::{self, Formatter}; use $crate::serde::de::IgnoredAny; #[allow(non_camel_case_types)] @@ -354,8 +354,8 @@ macro_rules! serde_struct_human_string_impl { macro_rules! impl_bytes_newtype { ($t:ident, $len:literal) => ( - impl ::core::fmt::LowerHex for $t { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + impl core::fmt::LowerHex for $t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { for &ch in self.0.iter() { write!(f, "{:02x}", ch)?; } @@ -363,24 +363,24 @@ macro_rules! impl_bytes_newtype { } } - impl ::core::fmt::Display for $t { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - ::core::fmt::LowerHex::fmt(self, f) + impl core::fmt::Display for $t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + core::fmt::LowerHex::fmt(self, f) } } - impl ::core::fmt::Debug for $t { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - ::core::fmt::LowerHex::fmt(self, f) + impl core::fmt::Debug for $t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + core::fmt::LowerHex::fmt(self, f) } } impl $crate::hashes::hex::FromHex for $t { fn from_byte_iter(iter: I) -> Result where - I: ::core::iter::Iterator> - + ::core::iter::ExactSizeIterator - + ::core::iter::DoubleEndedIterator, + I: core::iter::Iterator> + + core::iter::ExactSizeIterator + + core::iter::DoubleEndedIterator, { if iter.len() == $len { let mut ret = [0; $len]; @@ -394,7 +394,7 @@ macro_rules! impl_bytes_newtype { } } - impl ::core::str::FromStr for $t { + impl core::str::FromStr for $t { type Err = $crate::hashes::hex::Error; fn from_str(s: &str) -> Result { $crate::hashes::hex::FromHex::from_hex(s) @@ -423,7 +423,7 @@ macro_rules! impl_bytes_newtype { impl<'de> $crate::serde::de::Visitor<'de> for HexVisitor { type Value = $t; - fn expecting(&self, formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result { formatter.write_str("an ASCII hex string") } @@ -431,7 +431,7 @@ macro_rules! impl_bytes_newtype { where E: $crate::serde::de::Error, { - if let Ok(hex) = ::core::str::from_utf8(v) { + if let Ok(hex) = core::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)); @@ -453,7 +453,7 @@ macro_rules! impl_bytes_newtype { impl<'de> $crate::serde::de::Visitor<'de> for BytesVisitor { type Value = $t; - fn expecting(&self, formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result { formatter.write_str("a bytestring") } @@ -491,15 +491,15 @@ macro_rules! user_enum { $(#[$doc] $elem),* } - impl ::core::fmt::Display for $name { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + impl core::fmt::Display for $name { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.pad(match *self { $($name::$elem => $txt),* }) } } - impl ::core::str::FromStr for $name { + impl core::str::FromStr for $name { type Err = $crate::io::Error; #[inline] fn from_str(s: &str) -> Result { @@ -525,7 +525,7 @@ macro_rules! user_enum { where D: $crate::serde::Deserializer<'de>, { - use ::core::fmt::{self, Formatter}; + use core::fmt::{self, Formatter}; struct Visitor; impl<'de> $crate::serde::de::Visitor<'de> for Visitor { diff --git a/src/util/address.rs b/src/util/address.rs index 6b3d5409..47b956f5 100644 --- a/src/util/address.rs +++ b/src/util/address.rs @@ -254,7 +254,7 @@ impl WitnessVersion { /// If the integer does not correspond to any witness version, errors with /// [`Error::InvalidWitnessVersion`]. #[deprecated(since = "0.29.0", note = "use try_from instead")] - pub fn from_u5(value: ::bech32::u5) -> Result { + pub fn from_u5(value: bech32::u5) -> Result { Self::try_from(value) } @@ -422,10 +422,10 @@ impl<'a> TryFrom> for WitnessVersion { } } -impl From for ::bech32::u5 { +impl From for bech32::u5 { /// Converts [`WitnessVersion`] instance into corresponding Bech32(m) u5-value ([`bech32::u5`]). fn from(version: WitnessVersion) -> Self { - ::bech32::u5::try_from_u8(version.to_num()).expect("WitnessVersion must be 0..=16") + bech32::u5::try_from_u8(version.to_num()).expect("WitnessVersion must be 0..=16") } } diff --git a/src/util/amount.rs b/src/util/amount.rs index 2a250734..d23b9c23 100644 --- a/src/util/amount.rs +++ b/src/util/amount.rs @@ -779,7 +779,7 @@ impl FromStr for Amount { } } -impl ::core::iter::Sum for Amount { +impl core::iter::Sum for Amount { fn sum>(iter: I) -> Self { let sats: u64 = iter.map(|amt| amt.0).sum(); Amount::from_sat(sats) @@ -1210,7 +1210,7 @@ impl FromStr for SignedAmount { } } -impl ::core::iter::Sum for SignedAmount { +impl core::iter::Sum for SignedAmount { fn sum>(iter: I) -> Self { let sats: i64 = iter.map(|amt| amt.0).sum(); SignedAmount::from_sat(sats) diff --git a/src/util/bip32.rs b/src/util/bip32.rs index 5a380265..bcebdad2 100644 --- a/src/util/bip32.rs +++ b/src/util/bip32.rs @@ -285,13 +285,13 @@ impl<'a> From<&'a [ChildNumber]> for DerivationPath { } } -impl ::core::iter::FromIterator for DerivationPath { +impl core::iter::FromIterator for DerivationPath { fn from_iter(iter: T) -> Self where T: IntoIterator { DerivationPath(Vec::from_iter(iter)) } } -impl<'a> ::core::iter::IntoIterator for &'a DerivationPath { +impl<'a> core::iter::IntoIterator for &'a DerivationPath { type Item = &'a ChildNumber; type IntoIter = slice::Iter<'a, ChildNumber>; fn into_iter(self) -> Self::IntoIter { diff --git a/src/util/endian.rs b/src/util/endian.rs index dbe2c965..aac69b79 100644 --- a/src/util/endian.rs +++ b/src/util/endian.rs @@ -4,7 +4,7 @@ macro_rules! define_slice_to_be { ($name: ident, $type: ty) => { #[inline] pub fn $name(slice: &[u8]) -> $type { - assert_eq!(slice.len(), ::core::mem::size_of::<$type>()); + assert_eq!(slice.len(), core::mem::size_of::<$type>()); let mut res = 0; for i in 0..::core::mem::size_of::<$type>() { res |= (slice[i] as $type) << (::core::mem::size_of::<$type>() - i - 1)*8; @@ -17,7 +17,7 @@ macro_rules! define_slice_to_le { ($name: ident, $type: ty) => { #[inline] pub fn $name(slice: &[u8]) -> $type { - assert_eq!(slice.len(), ::core::mem::size_of::<$type>()); + assert_eq!(slice.len(), core::mem::size_of::<$type>()); let mut res = 0; for i in 0..::core::mem::size_of::<$type>() { res |= (slice[i] as $type) << i*8; @@ -93,7 +93,7 @@ macro_rules! define_chunk_slice_to_int { ($name: ident, $type: ty, $converter: ident) => { #[inline] pub fn $name(inp: &[u8], outp: &mut [$type]) { - assert_eq!(inp.len(), outp.len() * ::core::mem::size_of::<$type>()); + assert_eq!(inp.len(), outp.len() * core::mem::size_of::<$type>()); for (outp_val, data_bytes) in outp.iter_mut().zip(inp.chunks(::core::mem::size_of::<$type>())) { *outp_val = $converter(data_bytes); } diff --git a/src/util/key.rs b/src/util/key.rs index ebeffb25..8db1988a 100644 --- a/src/util/key.rs +++ b/src/util/key.rs @@ -427,30 +427,30 @@ impl ops::Index for PrivateKey { #[cfg(feature = "serde")] #[cfg_attr(docsrs, doc(cfg(feature = "serde")))] -impl ::serde::Serialize for PrivateKey { - fn serialize(&self, s: S) -> Result { +impl serde::Serialize for PrivateKey { + fn serialize(&self, s: S) -> Result { s.collect_str(self) } } #[cfg(feature = "serde")] #[cfg_attr(docsrs, doc(cfg(feature = "serde")))] -impl<'de> ::serde::Deserialize<'de> for PrivateKey { - fn deserialize>(d: D) -> Result { +impl<'de> serde::Deserialize<'de> for PrivateKey { + fn deserialize>(d: D) -> Result { struct WifVisitor; - impl<'de> ::serde::de::Visitor<'de> for WifVisitor { + impl<'de> serde::de::Visitor<'de> for WifVisitor { type Value = PrivateKey; - fn expecting(&self, formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result { formatter.write_str("an ASCII WIF string") } fn visit_bytes(self, v: &[u8]) -> Result where - E: ::serde::de::Error, + E: serde::de::Error, { - if let Ok(s) = ::core::str::from_utf8(v) { + if let Ok(s) = core::str::from_utf8(v) { PrivateKey::from_str(s).map_err(E::custom) } else { Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self)) @@ -459,7 +459,7 @@ impl<'de> ::serde::Deserialize<'de> for PrivateKey { fn visit_str(self, v: &str) -> Result where - E: ::serde::de::Error, + E: serde::de::Error, { PrivateKey::from_str(v).map_err(E::custom) } @@ -472,8 +472,8 @@ impl<'de> ::serde::Deserialize<'de> for PrivateKey { #[cfg(feature = "serde")] #[cfg_attr(docsrs, doc(cfg(feature = "serde")))] #[allow(clippy::collapsible_else_if)] // Aids readability. -impl ::serde::Serialize for PublicKey { - fn serialize(&self, s: S) -> Result { +impl serde::Serialize for PublicKey { + fn serialize(&self, s: S) -> Result { if s.is_human_readable() { s.collect_str(self) } else { @@ -488,23 +488,23 @@ impl ::serde::Serialize for PublicKey { #[cfg(feature = "serde")] #[cfg_attr(docsrs, doc(cfg(feature = "serde")))] -impl<'de> ::serde::Deserialize<'de> for PublicKey { - fn deserialize>(d: D) -> Result { +impl<'de> serde::Deserialize<'de> for PublicKey { + fn deserialize>(d: D) -> Result { if d.is_human_readable() { struct HexVisitor; - impl<'de> ::serde::de::Visitor<'de> for HexVisitor { + impl<'de> serde::de::Visitor<'de> for HexVisitor { type Value = PublicKey; - fn expecting(&self, formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result { formatter.write_str("an ASCII hex string") } fn visit_bytes(self, v: &[u8]) -> Result where - E: ::serde::de::Error, + E: serde::de::Error, { - if let Ok(hex) = ::core::str::from_utf8(v) { + if let Ok(hex) = core::str::from_utf8(v) { PublicKey::from_str(hex).map_err(E::custom) } else { Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self)) @@ -513,7 +513,7 @@ impl<'de> ::serde::Deserialize<'de> for PublicKey { fn visit_str(self, v: &str) -> Result where - E: ::serde::de::Error, + E: serde::de::Error, { PublicKey::from_str(v).map_err(E::custom) } @@ -522,16 +522,16 @@ impl<'de> ::serde::Deserialize<'de> for PublicKey { } else { struct BytesVisitor; - impl<'de> ::serde::de::Visitor<'de> for BytesVisitor { + impl<'de> serde::de::Visitor<'de> for BytesVisitor { type Value = PublicKey; - fn expecting(&self, formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result { formatter.write_str("a bytestring") } fn visit_bytes(self, v: &[u8]) -> Result where - E: ::serde::de::Error, + E: serde::de::Error, { PublicKey::from_slice(v).map_err(E::custom) } diff --git a/src/util/misc.rs b/src/util/misc.rs index d9584a4f..04640b83 100644 --- a/src/util/misc.rs +++ b/src/util/misc.rs @@ -172,7 +172,7 @@ mod message_signing { #[cfg(feature = "base64")] #[cfg_attr(docsrs, doc(cfg(feature = "base64")))] pub fn from_base64(s: &str) -> Result { - let bytes = ::base64::decode(s).map_err(|_| MessageSignatureError::InvalidBase64)?; + let bytes = base64::decode(s).map_err(|_| MessageSignatureError::InvalidBase64)?; MessageSignature::from_slice(&bytes) } @@ -180,7 +180,7 @@ mod message_signing { #[cfg(feature = "base64")] #[cfg_attr(docsrs, doc(cfg(feature = "base64")))] pub fn to_base64(&self) -> String { - ::base64::encode(&self.serialize()[..]) + base64::encode(&self.serialize()[..]) } } @@ -190,14 +190,14 @@ mod message_signing { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let bytes = self.serialize(); // This avoids the allocation of a String. - write!(f, "{}", ::base64::display::Base64Display::with_config( - &bytes[..], ::base64::STANDARD)) + write!(f, "{}", base64::display::Base64Display::with_config( + &bytes[..], base64::STANDARD)) } } #[cfg(feature = "base64")] #[cfg_attr(docsrs, doc(cfg(feature = "base64")))] - impl ::core::str::FromStr for MessageSignature { + impl core::str::FromStr for MessageSignature { type Err = MessageSignatureError; fn from_str(s: &str) -> Result { MessageSignature::from_base64(s) diff --git a/src/util/psbt/macros.rs b/src/util/psbt/macros.rs index d200970a..49760550 100644 --- a/src/util/psbt/macros.rs +++ b/src/util/psbt/macros.rs @@ -59,7 +59,7 @@ macro_rules! impl_psbtmap_consensus_decoding { fn consensus_decode( r: &mut R, ) -> Result { - let mut rv: Self = ::core::default::Default::default(); + let mut rv: Self = core::default::Default::default(); loop { match $crate::consensus::Decodable::consensus_decode(r) { diff --git a/src/util/psbt/mod.rs b/src/util/psbt/mod.rs index 32bb18ac..4bfdd7e2 100644 --- a/src/util/psbt/mod.rs +++ b/src/util/psbt/mod.rs @@ -246,7 +246,7 @@ mod display_from_str { #[cfg_attr(docsrs, doc(cfg(feature = "base64")))] impl Display for PartiallySignedTransaction { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!(f, "{}", Base64Display::with_config(&encode::serialize(self), ::base64::STANDARD)) + write!(f, "{}", Base64Display::with_config(&encode::serialize(self), base64::STANDARD)) } } @@ -255,7 +255,7 @@ mod display_from_str { type Err = PsbtParseError; fn from_str(s: &str) -> Result { - let data = ::base64::decode(s).map_err(PsbtParseError::Base64Encoding)?; + let data = base64::decode(s).map_err(PsbtParseError::Base64Encoding)?; encode::deserialize(&data).map_err(PsbtParseError::PsbtEncoding) } } @@ -582,8 +582,8 @@ mod tests { ..Default::default() }], }; - let encoded = ::serde_json::to_string(&psbt).unwrap(); - let decoded: PartiallySignedTransaction = ::serde_json::from_str(&encoded).unwrap(); + let encoded = serde_json::to_string(&psbt).unwrap(); + let decoded: PartiallySignedTransaction = serde_json::from_str(&encoded).unwrap(); assert_eq!(psbt, decoded); } diff --git a/src/util/taproot.rs b/src/util/taproot.rs index 8d77a501..8a3b776d 100644 --- a/src/util/taproot.rs +++ b/src/util/taproot.rs @@ -957,10 +957,10 @@ impl fmt::UpperHex for LeafVersion { /// Serializes [`LeafVersion`] as a `u8` using consensus encoding. #[cfg(feature = "serde")] #[cfg_attr(docsrs, doc(cfg(feature = "serde")))] -impl ::serde::Serialize for LeafVersion { +impl serde::Serialize for LeafVersion { fn serialize(&self, serializer: S) -> Result where - S: ::serde::Serializer, + S: serde::Serializer, { serializer.serialize_u8(self.to_consensus()) } @@ -969,13 +969,13 @@ impl ::serde::Serialize for LeafVersion { /// Deserializes [`LeafVersion`] as a `u8` using consensus encoding. #[cfg(feature = "serde")] #[cfg_attr(docsrs, doc(cfg(feature = "serde")))] -impl<'de> ::serde::Deserialize<'de> for LeafVersion { +impl<'de> serde::Deserialize<'de> for LeafVersion { fn deserialize(deserializer: D) -> Result where - D: ::serde::Deserializer<'de> + D: serde::Deserializer<'de> { struct U8Visitor; - impl<'de> ::serde::de::Visitor<'de> for U8Visitor { + impl<'de> serde::de::Visitor<'de> for U8Visitor { type Value = LeafVersion; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { @@ -984,7 +984,7 @@ impl<'de> ::serde::Deserialize<'de> for LeafVersion { fn visit_u8(self, value: u8) -> Result where - E: ::serde::de::Error, + E: serde::de::Error, { LeafVersion::from_consensus(value).map_err(|_| { E::invalid_value(::serde::de::Unexpected::Unsigned(value as u64), &"consensus-encoded leaf version as u8") diff --git a/src/util/uint.rs b/src/util/uint.rs index 301da631..0609b7de 100644 --- a/src/util/uint.rs +++ b/src/util/uint.rs @@ -167,30 +167,30 @@ macro_rules! construct_uint { impl PartialOrd for $name { #[inline] - fn partial_cmp(&self, other: &$name) -> Option<::core::cmp::Ordering> { + fn partial_cmp(&self, other: &$name) -> Option { Some(self.cmp(&other)) } } impl Ord for $name { #[inline] - fn cmp(&self, other: &$name) -> ::core::cmp::Ordering { + fn cmp(&self, other: &$name) -> core::cmp::Ordering { // We need to manually implement ordering because we use little-endian // and the auto derive is a lexicographic ordering(i.e. memcmp) // which with numbers is equivalent to big-endian for i in 0..$n_words { if self[$n_words - 1 - i] < other[$n_words - 1 - i] { - return ::core::cmp::Ordering::Less; + return core::cmp::Ordering::Less; } if self[$n_words - 1 - i] > other[$n_words - 1 - i] { - return ::core::cmp::Ordering::Greater; + return core::cmp::Ordering::Greater; } } - ::core::cmp::Ordering::Equal + core::cmp::Ordering::Equal } } - impl ::core::ops::Add<$name> for $name { + impl core::ops::Add<$name> for $name { type Output = $name; fn add(self, other: $name) -> $name { @@ -210,7 +210,7 @@ macro_rules! construct_uint { } } - impl ::core::ops::Sub<$name> for $name { + impl core::ops::Sub<$name> for $name { type Output = $name; #[inline] @@ -219,7 +219,7 @@ macro_rules! construct_uint { } } - impl ::core::ops::Mul<$name> for $name { + impl core::ops::Mul<$name> for $name { type Output = $name; fn mul(self, other: $name) -> $name { @@ -234,7 +234,7 @@ macro_rules! construct_uint { } } - impl ::core::ops::Div<$name> for $name { + impl core::ops::Div<$name> for $name { type Output = $name; fn div(self, other: $name) -> $name { @@ -242,7 +242,7 @@ macro_rules! construct_uint { } } - impl ::core::ops::Rem<$name> for $name { + impl core::ops::Rem<$name> for $name { type Output = $name; fn rem(self, other: $name) -> $name { @@ -292,7 +292,7 @@ macro_rules! construct_uint { } } - impl ::core::ops::BitAnd<$name> for $name { + impl core::ops::BitAnd<$name> for $name { type Output = $name; #[inline] @@ -307,7 +307,7 @@ macro_rules! construct_uint { } } - impl ::core::ops::BitXor<$name> for $name { + impl core::ops::BitXor<$name> for $name { type Output = $name; #[inline] @@ -322,7 +322,7 @@ macro_rules! construct_uint { } } - impl ::core::ops::BitOr<$name> for $name { + impl core::ops::BitOr<$name> for $name { type Output = $name; #[inline] @@ -337,7 +337,7 @@ macro_rules! construct_uint { } } - impl ::core::ops::Not for $name { + impl core::ops::Not for $name { type Output = $name; #[inline] @@ -351,7 +351,7 @@ macro_rules! construct_uint { } } - impl ::core::ops::Shl for $name { + impl core::ops::Shl for $name { type Output = $name; fn shl(self, shift: usize) -> $name { @@ -373,7 +373,7 @@ macro_rules! construct_uint { } } - impl ::core::ops::Shr for $name { + impl core::ops::Shr for $name { type Output = $name; fn shr(self, shift: usize) -> $name { @@ -393,8 +393,8 @@ macro_rules! construct_uint { } } - impl ::core::fmt::Debug for $name { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + impl core::fmt::Debug for $name { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { let &$name(ref data) = self; write!(f, "0x")?; for ch in data.iter().rev() { @@ -457,7 +457,7 @@ macro_rules! construct_uint { fn deserialize>( deserializer: D, ) -> Result { - use ::core::fmt; + use core::fmt; use $crate::hashes::hex::FromHex; use $crate::serde::de; struct Visitor; @@ -509,8 +509,8 @@ pub struct ParseLengthError { pub expected: usize, } -impl ::core::fmt::Display for ParseLengthError { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { +impl core::fmt::Display for ParseLengthError { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "Invalid length: got {}, expected {}", self.actual, self.expected) } } @@ -776,8 +776,8 @@ mod tests { assert_eq!(::serde_json::to_string(&uint).unwrap(), json); assert_eq!(::serde_json::from_str::(&json).unwrap(), uint); - let bin_encoded = ::bincode::serialize(&uint).unwrap(); - let bin_decoded: Uint256 = ::bincode::deserialize(&bin_encoded).unwrap(); + let bin_encoded = bincode::serialize(&uint).unwrap(); + let bin_decoded: Uint256 = bincode::deserialize(&bin_encoded).unwrap(); assert_eq!(bin_decoded, uint); };