Merge rust-bitcoin/rust-bitcoin#1001: Remove leading colons

73bc2bb058 Remove leading colons from ::core::cmp::Ordering (Tobin C. Harding)
bffe0e840d Remove _most_ leading double colons (Tobin C. Harding)

Pull request description:

  Leading double colons are a relic of edition 2015. Attempt to remove _all_ leading double colons (assuming I didn't miss any).

  - Patch 1 is done mechanically so it can be repeated by reviewers, just search-and-replace ' ::' with '::' (note the leading space).
  - Patch 2 does a single other instance of leading `::`

ACKs for top commit:
  apoelstra:
    ACK 73bc2bb058
  sanket1729:
    utACK 73bc2bb058.

Tree-SHA512: 8f7aafdda1aed5b69dcc83f544e65085dfec6590765839f0a6f259b99872805d1f00602fd9deac05c80a5cac3bc222d454dde0117dff4484e5cd34ea930fdfa1
This commit is contained in:
Andrew Poelstra 2022-07-19 01:38:46 +00:00
commit 0c22359618
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
13 changed files with 108 additions and 108 deletions

View File

@ -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<Self, hex::Error> {
hex::FromHex::from_hex(s)
@ -303,7 +303,7 @@ pub fn read_uint(data: &[u8], size: usize) -> Result<usize, Error> {
// 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<usize, UintError> {
fn read_uint_iter(data: &mut core::slice::Iter<'_, u8>, size: usize) -> Result<usize, UintError> {
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]

View File

@ -152,7 +152,7 @@ fn parse_vout(s: &str) -> Result<u32, ParseOutPointError> {
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<Self, Self::Err> {
@ -880,7 +880,7 @@ impl Transaction {
where
S: FnMut(&OutPoint) -> Option<TxOut>
{
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.

View File

@ -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<u8> 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<I>(iter: I) -> Result<Self, $crate::hashes::hex::Error>
where
I: ::core::iter::Iterator<Item=Result<u8, $crate::hashes::hex::Error>>
+ ::core::iter::ExactSizeIterator
+ ::core::iter::DoubleEndedIterator,
I: core::iter::Iterator<Item=Result<u8, $crate::hashes::hex::Error>>
+ 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<Self, Self::Err> {
$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<Self, Self::Err> {
@ -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 {

View File

@ -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<Self, Error> {
pub fn from_u5(value: bech32::u5) -> Result<Self, Error> {
Self::try_from(value)
}
@ -422,10 +422,10 @@ impl<'a> TryFrom<Instruction<'a>> for WitnessVersion {
}
}
impl From<WitnessVersion> for ::bech32::u5 {
impl From<WitnessVersion> 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")
}
}

View File

@ -779,7 +779,7 @@ impl FromStr for Amount {
}
}
impl ::core::iter::Sum for Amount {
impl core::iter::Sum for Amount {
fn sum<I: Iterator<Item = Self>>(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<I: Iterator<Item = Self>>(iter: I) -> Self {
let sats: i64 = iter.map(|amt| amt.0).sum();
SignedAmount::from_sat(sats)

View File

@ -285,13 +285,13 @@ impl<'a> From<&'a [ChildNumber]> for DerivationPath {
}
}
impl ::core::iter::FromIterator<ChildNumber> for DerivationPath {
impl core::iter::FromIterator<ChildNumber> for DerivationPath {
fn from_iter<T>(iter: T) -> Self where T: IntoIterator<Item=ChildNumber> {
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 {

View File

@ -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);
}

View File

@ -427,30 +427,30 @@ impl ops::Index<ops::RangeFull> for PrivateKey {
#[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl ::serde::Serialize for PrivateKey {
fn serialize<S: ::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
impl serde::Serialize for PrivateKey {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.collect_str(self)
}
}
#[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl<'de> ::serde::Deserialize<'de> for PrivateKey {
fn deserialize<D: ::serde::Deserializer<'de>>(d: D) -> Result<PrivateKey, D::Error> {
impl<'de> serde::Deserialize<'de> for PrivateKey {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<PrivateKey, D::Error> {
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<E>(self, v: &[u8]) -> Result<Self::Value, E>
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<E>(self, v: &str) -> Result<Self::Value, E>
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<S: ::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
impl serde::Serialize for PublicKey {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
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: ::serde::Deserializer<'de>>(d: D) -> Result<PublicKey, D::Error> {
impl<'de> serde::Deserialize<'de> for PublicKey {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<PublicKey, D::Error> {
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<E>(self, v: &[u8]) -> Result<Self::Value, E>
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<E>(self, v: &str) -> Result<Self::Value, E>
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<E>(self, v: &[u8]) -> Result<Self::Value, E>
where
E: ::serde::de::Error,
E: serde::de::Error,
{
PublicKey::from_slice(v).map_err(E::custom)
}

View File

@ -172,7 +172,7 @@ mod message_signing {
#[cfg(feature = "base64")]
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
pub fn from_base64(s: &str) -> Result<MessageSignature, MessageSignatureError> {
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, MessageSignatureError> {
MessageSignature::from_base64(s)

View File

@ -59,7 +59,7 @@ macro_rules! impl_psbtmap_consensus_decoding {
fn consensus_decode<R: $crate::io::Read + ?Sized>(
r: &mut R,
) -> Result<Self, $crate::consensus::encode::Error> {
let mut rv: Self = ::core::default::Default::default();
let mut rv: Self = core::default::Default::default();
loop {
match $crate::consensus::Decodable::consensus_decode(r) {

View File

@ -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<Self, Self::Err> {
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);
}

View File

@ -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<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
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<D>(deserializer: D) -> Result<Self, D::Error>
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<E>(self, value: u8) -> Result<Self::Value, E>
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")

View File

@ -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<core::cmp::Ordering> {
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<usize> for $name {
impl core::ops::Shl<usize> for $name {
type Output = $name;
fn shl(self, shift: usize) -> $name {
@ -373,7 +373,7 @@ macro_rules! construct_uint {
}
}
impl ::core::ops::Shr<usize> for $name {
impl core::ops::Shr<usize> 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<D: $crate::serde::Deserializer<'de>>(
deserializer: D,
) -> Result<Self, D::Error> {
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::<Uint256>(&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);
};