Remove _most_ leading double colons
Leading double colons are a relic of edition 2015. Remove all leading double colons that follow a space, done like this so that reviewers can do the same and verify the diff. Done with search-and-replace ' ::' '::' And, for the record: ```bash function search-and-replace() { if (($# != 2)) then echo "Usage: $0 <this> <that>" return fi local this="$1" local that="$2" for file in $(git grep -l "$this") do perl -pi -e "s/$this/$that/g" "$file" done } ```
This commit is contained in:
parent
97c680db8c
commit
bffe0e840d
|
@ -123,7 +123,7 @@ impl hex::FromHex for Script {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::str::FromStr for Script {
|
impl core::str::FromStr for Script {
|
||||||
type Err = hex::Error;
|
type Err = hex::Error;
|
||||||
fn from_str(s: &str) -> Result<Self, hex::Error> {
|
fn from_str(s: &str) -> Result<Self, hex::Error> {
|
||||||
hex::FromHex::from_hex(s)
|
hex::FromHex::from_hex(s)
|
||||||
|
@ -314,7 +314,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
|
// We internally use implementation based on iterator so that it automatically advances as needed
|
||||||
// Errors are same as above, just different type.
|
// 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 {
|
if data.len() < size {
|
||||||
Err(UintError::EarlyEndOfScript)
|
Err(UintError::EarlyEndOfScript)
|
||||||
} else if size > usize::from(u16::max_value() / 8) {
|
} else if size > usize::from(u16::max_value() / 8) {
|
||||||
|
@ -637,7 +637,7 @@ impl Script {
|
||||||
#[cfg(feature="bitcoinconsensus")]
|
#[cfg(feature="bitcoinconsensus")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoinconsensus")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoinconsensus")))]
|
||||||
pub fn verify (&self, index: usize, amount: crate::Amount, spending: &[u8]) -> Result<(), Error> {
|
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.
|
/// Verifies spend of an input script.
|
||||||
|
@ -767,7 +767,7 @@ pub enum Instruction<'a> {
|
||||||
|
|
||||||
/// Iterator over a script returning parsed opcodes.
|
/// Iterator over a script returning parsed opcodes.
|
||||||
pub struct Instructions<'a> {
|
pub struct Instructions<'a> {
|
||||||
data: ::core::slice::Iter<'a, u8>,
|
data: core::slice::Iter<'a, u8>,
|
||||||
enforce_minimal: bool,
|
enforce_minimal: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,7 +863,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 {
|
impl Builder {
|
||||||
/// Creates a new empty script.
|
/// Creates a new empty script.
|
||||||
|
@ -1501,14 +1501,14 @@ mod test {
|
||||||
let script = Script::from(vec![0u8, 1u8, 2u8]);
|
let script = Script::from(vec![0u8, 1u8, 2u8]);
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
let json = ::serde_json::to_string(&script).unwrap();
|
let json = serde_json::to_string(&script).unwrap();
|
||||||
assert_eq!(json, "\"000102\"");
|
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
|
assert_eq!(bincode, [3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2]); // bincode adds u64 for length, serde_cbor use varint
|
||||||
|
|
||||||
// Deserialize
|
// Deserialize
|
||||||
assert_eq!(script, ::serde_json::from_str(&json).unwrap());
|
assert_eq!(script, serde_json::from_str(&json).unwrap());
|
||||||
assert_eq!(script, ::bincode::deserialize(&bincode).unwrap());
|
assert_eq!(script, bincode::deserialize(&bincode).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -162,7 +162,7 @@ fn parse_vout(s: &str) -> Result<u32, ParseOutPointError> {
|
||||||
s.parse().map_err(ParseOutPointError::Vout)
|
s.parse().map_err(ParseOutPointError::Vout)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::str::FromStr for OutPoint {
|
impl core::str::FromStr for OutPoint {
|
||||||
type Err = ParseOutPointError;
|
type Err = ParseOutPointError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
@ -690,7 +690,7 @@ impl Transaction {
|
||||||
where
|
where
|
||||||
S: FnMut(&OutPoint) -> Option<TxOut>
|
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.
|
/// Verify that this transaction is able to spend its inputs.
|
||||||
|
|
|
@ -121,15 +121,15 @@ macro_rules! impl_array_newtype {
|
||||||
macro_rules! display_from_debug {
|
macro_rules! display_from_debug {
|
||||||
($thing:ident) => {
|
($thing:ident) => {
|
||||||
impl core::fmt::Display for $thing {
|
impl core::fmt::Display for $thing {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> Result<(), ::core::fmt::Error> {
|
fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
|
||||||
::core::fmt::Debug::fmt(self, f)
|
core::fmt::Debug::fmt(self, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[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)]
|
#[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()));
|
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()));
|
||||||
|
@ -146,8 +146,8 @@ macro_rules! serde_string_impl {
|
||||||
where
|
where
|
||||||
D: $crate::serde::de::Deserializer<'de>,
|
D: $crate::serde::de::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
use ::core::fmt::{self, Formatter};
|
use core::fmt::{self, Formatter};
|
||||||
use ::core::str::FromStr;
|
use core::str::FromStr;
|
||||||
|
|
||||||
struct Visitor;
|
struct Visitor;
|
||||||
impl<'de> $crate::serde::de::Visitor<'de> for Visitor {
|
impl<'de> $crate::serde::de::Visitor<'de> for Visitor {
|
||||||
|
@ -194,8 +194,8 @@ macro_rules! serde_struct_human_string_impl {
|
||||||
D: $crate::serde::de::Deserializer<'de>,
|
D: $crate::serde::de::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
if deserializer.is_human_readable() {
|
if deserializer.is_human_readable() {
|
||||||
use ::core::fmt::{self, Formatter};
|
use core::fmt::{self, Formatter};
|
||||||
use ::core::str::FromStr;
|
use core::str::FromStr;
|
||||||
|
|
||||||
struct Visitor;
|
struct Visitor;
|
||||||
impl<'de> $crate::serde::de::Visitor<'de> for Visitor {
|
impl<'de> $crate::serde::de::Visitor<'de> for Visitor {
|
||||||
|
@ -216,7 +216,7 @@ macro_rules! serde_struct_human_string_impl {
|
||||||
|
|
||||||
deserializer.deserialize_str(Visitor)
|
deserializer.deserialize_str(Visitor)
|
||||||
} else {
|
} else {
|
||||||
use ::core::fmt::{self, Formatter};
|
use core::fmt::{self, Formatter};
|
||||||
use $crate::serde::de::IgnoredAny;
|
use $crate::serde::de::IgnoredAny;
|
||||||
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
|
@ -365,8 +365,8 @@ macro_rules! serde_struct_human_string_impl {
|
||||||
macro_rules! impl_bytes_newtype {
|
macro_rules! impl_bytes_newtype {
|
||||||
($t:ident, $len:literal) => (
|
($t:ident, $len:literal) => (
|
||||||
|
|
||||||
impl ::core::fmt::LowerHex for $t {
|
impl core::fmt::LowerHex for $t {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||||
for &ch in self.0.iter() {
|
for &ch in self.0.iter() {
|
||||||
write!(f, "{:02x}", ch)?;
|
write!(f, "{:02x}", ch)?;
|
||||||
}
|
}
|
||||||
|
@ -374,24 +374,24 @@ macro_rules! impl_bytes_newtype {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Display for $t {
|
impl core::fmt::Display for $t {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||||
::core::fmt::LowerHex::fmt(self, f)
|
core::fmt::LowerHex::fmt(self, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for $t {
|
impl core::fmt::Debug for $t {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||||
::core::fmt::LowerHex::fmt(self, f)
|
core::fmt::LowerHex::fmt(self, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl $crate::hashes::hex::FromHex for $t {
|
impl $crate::hashes::hex::FromHex for $t {
|
||||||
fn from_byte_iter<I>(iter: I) -> Result<Self, $crate::hashes::hex::Error>
|
fn from_byte_iter<I>(iter: I) -> Result<Self, $crate::hashes::hex::Error>
|
||||||
where
|
where
|
||||||
I: ::core::iter::Iterator<Item=Result<u8, $crate::hashes::hex::Error>>
|
I: core::iter::Iterator<Item=Result<u8, $crate::hashes::hex::Error>>
|
||||||
+ ::core::iter::ExactSizeIterator
|
+ core::iter::ExactSizeIterator
|
||||||
+ ::core::iter::DoubleEndedIterator,
|
+ core::iter::DoubleEndedIterator,
|
||||||
{
|
{
|
||||||
if iter.len() == $len {
|
if iter.len() == $len {
|
||||||
let mut ret = [0; $len];
|
let mut ret = [0; $len];
|
||||||
|
@ -405,7 +405,7 @@ macro_rules! impl_bytes_newtype {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::str::FromStr for $t {
|
impl core::str::FromStr for $t {
|
||||||
type Err = $crate::hashes::hex::Error;
|
type Err = $crate::hashes::hex::Error;
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
$crate::hashes::hex::FromHex::from_hex(s)
|
$crate::hashes::hex::FromHex::from_hex(s)
|
||||||
|
@ -434,7 +434,7 @@ macro_rules! impl_bytes_newtype {
|
||||||
impl<'de> $crate::serde::de::Visitor<'de> for HexVisitor {
|
impl<'de> $crate::serde::de::Visitor<'de> for HexVisitor {
|
||||||
type Value = $t;
|
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")
|
formatter.write_str("an ASCII hex string")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ macro_rules! impl_bytes_newtype {
|
||||||
where
|
where
|
||||||
E: $crate::serde::de::Error,
|
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)
|
$crate::hashes::hex::FromHex::from_hex(hex).map_err(E::custom)
|
||||||
} else {
|
} else {
|
||||||
return Err(E::invalid_value($crate::serde::de::Unexpected::Bytes(v), &self));
|
return Err(E::invalid_value($crate::serde::de::Unexpected::Bytes(v), &self));
|
||||||
|
@ -464,7 +464,7 @@ macro_rules! impl_bytes_newtype {
|
||||||
impl<'de> $crate::serde::de::Visitor<'de> for BytesVisitor {
|
impl<'de> $crate::serde::de::Visitor<'de> for BytesVisitor {
|
||||||
type Value = $t;
|
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")
|
formatter.write_str("a bytestring")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,15 +502,15 @@ macro_rules! user_enum {
|
||||||
$(#[$doc] $elem),*
|
$(#[$doc] $elem),*
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Display for $name {
|
impl core::fmt::Display for $name {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||||
f.pad(match *self {
|
f.pad(match *self {
|
||||||
$($name::$elem => $txt),*
|
$($name::$elem => $txt),*
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::str::FromStr for $name {
|
impl core::str::FromStr for $name {
|
||||||
type Err = $crate::io::Error;
|
type Err = $crate::io::Error;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
@ -536,7 +536,7 @@ macro_rules! user_enum {
|
||||||
where
|
where
|
||||||
D: $crate::serde::Deserializer<'de>,
|
D: $crate::serde::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
use ::core::fmt::{self, Formatter};
|
use core::fmt::{self, Formatter};
|
||||||
|
|
||||||
struct Visitor;
|
struct Visitor;
|
||||||
impl<'de> $crate::serde::de::Visitor<'de> for Visitor {
|
impl<'de> $crate::serde::de::Visitor<'de> for Visitor {
|
||||||
|
|
|
@ -260,7 +260,7 @@ impl WitnessVersion {
|
||||||
/// If the integer does not correspond to any witness version, errors with
|
/// If the integer does not correspond to any witness version, errors with
|
||||||
/// [`Error::InvalidWitnessVersion`].
|
/// [`Error::InvalidWitnessVersion`].
|
||||||
#[deprecated(since = "0.29.0", note = "use try_from instead")]
|
#[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)
|
Self::try_from(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,10 +428,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`]).
|
/// Converts [`WitnessVersion`] instance into corresponding Bech32(m) u5-value ([`bech32::u5`]).
|
||||||
fn from(version: WitnessVersion) -> Self {
|
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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -772,7 +772,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 {
|
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
|
||||||
let sats: u64 = iter.map(|amt| amt.0).sum();
|
let sats: u64 = iter.map(|amt| amt.0).sum();
|
||||||
Amount::from_sat(sats)
|
Amount::from_sat(sats)
|
||||||
|
@ -1203,7 +1203,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 {
|
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
|
||||||
let sats: i64 = iter.map(|amt| amt.0).sum();
|
let sats: i64 = iter.map(|amt| amt.0).sum();
|
||||||
SignedAmount::from_sat(sats)
|
SignedAmount::from_sat(sats)
|
||||||
|
|
|
@ -295,13 +295,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> {
|
fn from_iter<T>(iter: T) -> Self where T: IntoIterator<Item=ChildNumber> {
|
||||||
DerivationPath(Vec::from_iter(iter))
|
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 Item = &'a ChildNumber;
|
||||||
type IntoIter = slice::Iter<'a, ChildNumber>;
|
type IntoIter = slice::Iter<'a, ChildNumber>;
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
|
|
|
@ -2,7 +2,7 @@ macro_rules! define_slice_to_be {
|
||||||
($name: ident, $type: ty) => {
|
($name: ident, $type: ty) => {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $name(slice: &[u8]) -> $type {
|
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;
|
let mut res = 0;
|
||||||
for i in 0..::core::mem::size_of::<$type>() {
|
for i in 0..::core::mem::size_of::<$type>() {
|
||||||
res |= (slice[i] as $type) << (::core::mem::size_of::<$type>() - i - 1)*8;
|
res |= (slice[i] as $type) << (::core::mem::size_of::<$type>() - i - 1)*8;
|
||||||
|
@ -15,7 +15,7 @@ macro_rules! define_slice_to_le {
|
||||||
($name: ident, $type: ty) => {
|
($name: ident, $type: ty) => {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $name(slice: &[u8]) -> $type {
|
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;
|
let mut res = 0;
|
||||||
for i in 0..::core::mem::size_of::<$type>() {
|
for i in 0..::core::mem::size_of::<$type>() {
|
||||||
res |= (slice[i] as $type) << i*8;
|
res |= (slice[i] as $type) << i*8;
|
||||||
|
@ -91,7 +91,7 @@ macro_rules! define_chunk_slice_to_int {
|
||||||
($name: ident, $type: ty, $converter: ident) => {
|
($name: ident, $type: ty, $converter: ident) => {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $name(inp: &[u8], outp: &mut [$type]) {
|
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>())) {
|
for (outp_val, data_bytes) in outp.iter_mut().zip(inp.chunks(::core::mem::size_of::<$type>())) {
|
||||||
*outp_val = $converter(data_bytes);
|
*outp_val = $converter(data_bytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -367,30 +367,30 @@ impl ops::Index<ops::RangeFull> for PrivateKey {
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
|
||||||
impl ::serde::Serialize for PrivateKey {
|
impl serde::Serialize for PrivateKey {
|
||||||
fn serialize<S: ::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
|
||||||
s.collect_str(self)
|
s.collect_str(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
|
||||||
impl<'de> ::serde::Deserialize<'de> for PrivateKey {
|
impl<'de> serde::Deserialize<'de> for PrivateKey {
|
||||||
fn deserialize<D: ::serde::Deserializer<'de>>(d: D) -> Result<PrivateKey, D::Error> {
|
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<PrivateKey, D::Error> {
|
||||||
struct WifVisitor;
|
struct WifVisitor;
|
||||||
|
|
||||||
impl<'de> ::serde::de::Visitor<'de> for WifVisitor {
|
impl<'de> serde::de::Visitor<'de> for WifVisitor {
|
||||||
type Value = PrivateKey;
|
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")
|
formatter.write_str("an ASCII WIF string")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
|
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
|
||||||
where
|
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)
|
PrivateKey::from_str(s).map_err(E::custom)
|
||||||
} else {
|
} else {
|
||||||
Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self))
|
Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self))
|
||||||
|
@ -399,7 +399,7 @@ impl<'de> ::serde::Deserialize<'de> for PrivateKey {
|
||||||
|
|
||||||
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
|
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
|
||||||
where
|
where
|
||||||
E: ::serde::de::Error,
|
E: serde::de::Error,
|
||||||
{
|
{
|
||||||
PrivateKey::from_str(v).map_err(E::custom)
|
PrivateKey::from_str(v).map_err(E::custom)
|
||||||
}
|
}
|
||||||
|
@ -412,8 +412,8 @@ impl<'de> ::serde::Deserialize<'de> for PrivateKey {
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
|
||||||
#[allow(clippy::collapsible_else_if)] // Aids readability.
|
#[allow(clippy::collapsible_else_if)] // Aids readability.
|
||||||
impl ::serde::Serialize for PublicKey {
|
impl serde::Serialize for PublicKey {
|
||||||
fn serialize<S: ::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
|
||||||
if s.is_human_readable() {
|
if s.is_human_readable() {
|
||||||
s.collect_str(self)
|
s.collect_str(self)
|
||||||
} else {
|
} else {
|
||||||
|
@ -428,23 +428,23 @@ impl ::serde::Serialize for PublicKey {
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
|
||||||
impl<'de> ::serde::Deserialize<'de> for PublicKey {
|
impl<'de> serde::Deserialize<'de> for PublicKey {
|
||||||
fn deserialize<D: ::serde::Deserializer<'de>>(d: D) -> Result<PublicKey, D::Error> {
|
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<PublicKey, D::Error> {
|
||||||
if d.is_human_readable() {
|
if d.is_human_readable() {
|
||||||
struct HexVisitor;
|
struct HexVisitor;
|
||||||
|
|
||||||
impl<'de> ::serde::de::Visitor<'de> for HexVisitor {
|
impl<'de> serde::de::Visitor<'de> for HexVisitor {
|
||||||
type Value = PublicKey;
|
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")
|
formatter.write_str("an ASCII hex string")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
|
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
|
||||||
where
|
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)
|
PublicKey::from_str(hex).map_err(E::custom)
|
||||||
} else {
|
} else {
|
||||||
Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self))
|
Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self))
|
||||||
|
@ -453,7 +453,7 @@ impl<'de> ::serde::Deserialize<'de> for PublicKey {
|
||||||
|
|
||||||
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
|
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
|
||||||
where
|
where
|
||||||
E: ::serde::de::Error,
|
E: serde::de::Error,
|
||||||
{
|
{
|
||||||
PublicKey::from_str(v).map_err(E::custom)
|
PublicKey::from_str(v).map_err(E::custom)
|
||||||
}
|
}
|
||||||
|
@ -462,16 +462,16 @@ impl<'de> ::serde::Deserialize<'de> for PublicKey {
|
||||||
} else {
|
} else {
|
||||||
struct BytesVisitor;
|
struct BytesVisitor;
|
||||||
|
|
||||||
impl<'de> ::serde::de::Visitor<'de> for BytesVisitor {
|
impl<'de> serde::de::Visitor<'de> for BytesVisitor {
|
||||||
type Value = PublicKey;
|
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")
|
formatter.write_str("a bytestring")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
|
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
|
||||||
where
|
where
|
||||||
E: ::serde::de::Error,
|
E: serde::de::Error,
|
||||||
{
|
{
|
||||||
PublicKey::from_slice(v).map_err(E::custom)
|
PublicKey::from_slice(v).map_err(E::custom)
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ mod message_signing {
|
||||||
#[cfg(feature = "base64")]
|
#[cfg(feature = "base64")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
|
||||||
pub fn from_base64(s: &str) -> Result<MessageSignature, MessageSignatureError> {
|
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)
|
MessageSignature::from_slice(&bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ mod message_signing {
|
||||||
#[cfg(feature = "base64")]
|
#[cfg(feature = "base64")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
|
||||||
pub fn to_base64(&self) -> String {
|
pub fn to_base64(&self) -> String {
|
||||||
::base64::encode(&self.serialize()[..])
|
base64::encode(&self.serialize()[..])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,14 +201,14 @@ mod message_signing {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let bytes = self.serialize();
|
let bytes = self.serialize();
|
||||||
// This avoids the allocation of a String.
|
// This avoids the allocation of a String.
|
||||||
write!(f, "{}", ::base64::display::Base64Display::with_config(
|
write!(f, "{}", base64::display::Base64Display::with_config(
|
||||||
&bytes[..], ::base64::STANDARD))
|
&bytes[..], base64::STANDARD))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "base64")]
|
#[cfg(feature = "base64")]
|
||||||
#[cfg_attr(docsrs, doc(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;
|
type Err = MessageSignatureError;
|
||||||
fn from_str(s: &str) -> Result<MessageSignature, MessageSignatureError> {
|
fn from_str(s: &str) -> Result<MessageSignature, MessageSignatureError> {
|
||||||
MessageSignature::from_base64(s)
|
MessageSignature::from_base64(s)
|
||||||
|
|
|
@ -71,7 +71,7 @@ macro_rules! impl_psbtmap_consensus_decoding {
|
||||||
fn consensus_decode<R: $crate::io::Read + ?Sized>(
|
fn consensus_decode<R: $crate::io::Read + ?Sized>(
|
||||||
r: &mut R,
|
r: &mut R,
|
||||||
) -> Result<Self, $crate::consensus::encode::Error> {
|
) -> Result<Self, $crate::consensus::encode::Error> {
|
||||||
let mut rv: Self = ::core::default::Default::default();
|
let mut rv: Self = core::default::Default::default();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match $crate::consensus::Decodable::consensus_decode(r) {
|
match $crate::consensus::Decodable::consensus_decode(r) {
|
||||||
|
|
|
@ -258,7 +258,7 @@ mod display_from_str {
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
|
||||||
impl Display for PartiallySignedTransaction {
|
impl Display for PartiallySignedTransaction {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ mod display_from_str {
|
||||||
type Err = PsbtParseError;
|
type Err = PsbtParseError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
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)
|
encode::deserialize(&data).map_err(PsbtParseError::PsbtEncoding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -594,8 +594,8 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
let encoded = ::serde_json::to_string(&psbt).unwrap();
|
let encoded = serde_json::to_string(&psbt).unwrap();
|
||||||
let decoded: PartiallySignedTransaction = ::serde_json::from_str(&encoded).unwrap();
|
let decoded: PartiallySignedTransaction = serde_json::from_str(&encoded).unwrap();
|
||||||
assert_eq!(psbt, decoded);
|
assert_eq!(psbt, decoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -962,10 +962,10 @@ impl fmt::UpperHex for LeafVersion {
|
||||||
/// Serializes [`LeafVersion`] as a `u8` using consensus encoding.
|
/// Serializes [`LeafVersion`] as a `u8` using consensus encoding.
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
#[cfg_attr(docsrs, doc(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>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: ::serde::Serializer,
|
S: serde::Serializer,
|
||||||
{
|
{
|
||||||
serializer.serialize_u8(self.to_consensus())
|
serializer.serialize_u8(self.to_consensus())
|
||||||
}
|
}
|
||||||
|
@ -974,13 +974,13 @@ impl ::serde::Serialize for LeafVersion {
|
||||||
/// Deserializes [`LeafVersion`] as a `u8` using consensus encoding.
|
/// Deserializes [`LeafVersion`] as a `u8` using consensus encoding.
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
#[cfg_attr(docsrs, doc(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>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: ::serde::Deserializer<'de>
|
D: serde::Deserializer<'de>
|
||||||
{
|
{
|
||||||
struct U8Visitor;
|
struct U8Visitor;
|
||||||
impl<'de> ::serde::de::Visitor<'de> for U8Visitor {
|
impl<'de> serde::de::Visitor<'de> for U8Visitor {
|
||||||
type Value = LeafVersion;
|
type Value = LeafVersion;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
@ -989,7 +989,7 @@ impl<'de> ::serde::Deserialize<'de> for LeafVersion {
|
||||||
|
|
||||||
fn visit_u8<E>(self, value: u8) -> Result<Self::Value, E>
|
fn visit_u8<E>(self, value: u8) -> Result<Self::Value, E>
|
||||||
where
|
where
|
||||||
E: ::serde::de::Error,
|
E: serde::de::Error,
|
||||||
{
|
{
|
||||||
LeafVersion::from_consensus(value).map_err(|_| {
|
LeafVersion::from_consensus(value).map_err(|_| {
|
||||||
E::invalid_value(::serde::de::Unexpected::Unsigned(value as u64), &"consensus-encoded leaf version as u8")
|
E::invalid_value(::serde::de::Unexpected::Unsigned(value as u64), &"consensus-encoded leaf version as u8")
|
||||||
|
|
|
@ -185,23 +185,23 @@ macro_rules! construct_uint {
|
||||||
|
|
||||||
impl Ord for $name {
|
impl Ord for $name {
|
||||||
#[inline]
|
#[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
|
// We need to manually implement ordering because we use little-endian
|
||||||
// and the auto derive is a lexicographic ordering(i.e. memcmp)
|
// and the auto derive is a lexicographic ordering(i.e. memcmp)
|
||||||
// which with numbers is equivalent to big-endian
|
// which with numbers is equivalent to big-endian
|
||||||
for i in 0..$n_words {
|
for i in 0..$n_words {
|
||||||
if self[$n_words - 1 - i] < other[$n_words - 1 - i] {
|
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] {
|
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;
|
type Output = $name;
|
||||||
|
|
||||||
fn add(self, other: $name) -> $name {
|
fn add(self, other: $name) -> $name {
|
||||||
|
@ -221,7 +221,7 @@ macro_rules! construct_uint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::ops::Sub<$name> for $name {
|
impl core::ops::Sub<$name> for $name {
|
||||||
type Output = $name;
|
type Output = $name;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -230,7 +230,7 @@ macro_rules! construct_uint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::ops::Mul<$name> for $name {
|
impl core::ops::Mul<$name> for $name {
|
||||||
type Output = $name;
|
type Output = $name;
|
||||||
|
|
||||||
fn mul(self, other: $name) -> $name {
|
fn mul(self, other: $name) -> $name {
|
||||||
|
@ -245,7 +245,7 @@ macro_rules! construct_uint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::ops::Div<$name> for $name {
|
impl core::ops::Div<$name> for $name {
|
||||||
type Output = $name;
|
type Output = $name;
|
||||||
|
|
||||||
fn div(self, other: $name) -> $name {
|
fn div(self, other: $name) -> $name {
|
||||||
|
@ -253,7 +253,7 @@ macro_rules! construct_uint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::ops::Rem<$name> for $name {
|
impl core::ops::Rem<$name> for $name {
|
||||||
type Output = $name;
|
type Output = $name;
|
||||||
|
|
||||||
fn rem(self, other: $name) -> $name {
|
fn rem(self, other: $name) -> $name {
|
||||||
|
@ -303,7 +303,7 @@ macro_rules! construct_uint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::ops::BitAnd<$name> for $name {
|
impl core::ops::BitAnd<$name> for $name {
|
||||||
type Output = $name;
|
type Output = $name;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -318,7 +318,7 @@ macro_rules! construct_uint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::ops::BitXor<$name> for $name {
|
impl core::ops::BitXor<$name> for $name {
|
||||||
type Output = $name;
|
type Output = $name;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -333,7 +333,7 @@ macro_rules! construct_uint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::ops::BitOr<$name> for $name {
|
impl core::ops::BitOr<$name> for $name {
|
||||||
type Output = $name;
|
type Output = $name;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -348,7 +348,7 @@ macro_rules! construct_uint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::ops::Not for $name {
|
impl core::ops::Not for $name {
|
||||||
type Output = $name;
|
type Output = $name;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -362,7 +362,7 @@ macro_rules! construct_uint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::ops::Shl<usize> for $name {
|
impl core::ops::Shl<usize> for $name {
|
||||||
type Output = $name;
|
type Output = $name;
|
||||||
|
|
||||||
fn shl(self, shift: usize) -> $name {
|
fn shl(self, shift: usize) -> $name {
|
||||||
|
@ -384,7 +384,7 @@ macro_rules! construct_uint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::ops::Shr<usize> for $name {
|
impl core::ops::Shr<usize> for $name {
|
||||||
type Output = $name;
|
type Output = $name;
|
||||||
|
|
||||||
fn shr(self, shift: usize) -> $name {
|
fn shr(self, shift: usize) -> $name {
|
||||||
|
@ -404,8 +404,8 @@ macro_rules! construct_uint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for $name {
|
impl core::fmt::Debug for $name {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||||
let &$name(ref data) = self;
|
let &$name(ref data) = self;
|
||||||
write!(f, "0x")?;
|
write!(f, "0x")?;
|
||||||
for ch in data.iter().rev() {
|
for ch in data.iter().rev() {
|
||||||
|
@ -468,7 +468,7 @@ macro_rules! construct_uint {
|
||||||
fn deserialize<D: $crate::serde::Deserializer<'de>>(
|
fn deserialize<D: $crate::serde::Deserializer<'de>>(
|
||||||
deserializer: D,
|
deserializer: D,
|
||||||
) -> Result<Self, D::Error> {
|
) -> Result<Self, D::Error> {
|
||||||
use ::core::fmt;
|
use core::fmt;
|
||||||
use $crate::hashes::hex::FromHex;
|
use $crate::hashes::hex::FromHex;
|
||||||
use $crate::serde::de;
|
use $crate::serde::de;
|
||||||
struct Visitor;
|
struct Visitor;
|
||||||
|
@ -520,8 +520,8 @@ pub struct ParseLengthError {
|
||||||
pub expected: usize,
|
pub expected: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Display for ParseLengthError {
|
impl core::fmt::Display for ParseLengthError {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||||
write!(f, "Invalid length: got {}, expected {}", self.actual, self.expected)
|
write!(f, "Invalid length: got {}, expected {}", self.actual, self.expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -787,8 +787,8 @@ mod tests {
|
||||||
assert_eq!(::serde_json::to_string(&uint).unwrap(), json);
|
assert_eq!(::serde_json::to_string(&uint).unwrap(), json);
|
||||||
assert_eq!(::serde_json::from_str::<Uint256>(&json).unwrap(), uint);
|
assert_eq!(::serde_json::from_str::<Uint256>(&json).unwrap(), uint);
|
||||||
|
|
||||||
let bin_encoded = ::bincode::serialize(&uint).unwrap();
|
let bin_encoded = bincode::serialize(&uint).unwrap();
|
||||||
let bin_decoded: Uint256 = ::bincode::deserialize(&bin_encoded).unwrap();
|
let bin_decoded: Uint256 = bincode::deserialize(&bin_encoded).unwrap();
|
||||||
assert_eq!(bin_decoded, uint);
|
assert_eq!(bin_decoded, uint);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue