From b9f704955ab210241b7338669c3859f024a35de2 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sat, 13 Mar 2021 09:12:52 +1300 Subject: [PATCH] zcash_address: Move ZcashAddress::convert into root Using two separate `impl ZcashAddress` blocks resulted in separate blocks in the documentation, which is unnecessary. --- components/zcash_address/src/convert.rs | 16 +++------------- components/zcash_address/src/lib.rs | 10 ++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/components/zcash_address/src/convert.rs b/components/zcash_address/src/convert.rs index 50a500ad4..ec6685a18 100644 --- a/components/zcash_address/src/convert.rs +++ b/components/zcash_address/src/convert.rs @@ -1,6 +1,6 @@ use std::{error::Error, fmt}; -use crate::{kind::*, AddressKind, Network, ZcashAddress}; +use crate::{kind::*, Network}; /// An address type is not supported for conversion. #[derive(Debug)] @@ -14,20 +14,10 @@ impl fmt::Display for UnsupportedAddress { impl Error for UnsupportedAddress {} -impl ZcashAddress { - pub fn convert(self) -> Result { - match self.kind { - AddressKind::Sprout(data) => T::from_sprout(self.net, data), - AddressKind::Sapling(data) => T::from_sapling(self.net, data), - AddressKind::Orchard(data) => T::from_orchard(self.net, data), - AddressKind::P2pkh(data) => T::from_transparent_p2pkh(self.net, data), - AddressKind::P2sh(data) => T::from_transparent_p2sh(self.net, data), - } - } -} - /// A helper trait for converting a [`ZcashAddress`] into another type. /// +/// [`ZcashAddress`]: crate::ZcashAddress +/// /// # Examples /// /// ``` diff --git a/components/zcash_address/src/lib.rs b/components/zcash_address/src/lib.rs index ea52e678c..eca983247 100644 --- a/components/zcash_address/src/lib.rs +++ b/components/zcash_address/src/lib.rs @@ -70,4 +70,14 @@ impl ZcashAddress { pub fn try_from_encoded(s: &str) -> Result { s.parse() } + + pub fn convert(self) -> Result { + match self.kind { + AddressKind::Sprout(data) => T::from_sprout(self.net, data), + AddressKind::Sapling(data) => T::from_sapling(self.net, data), + AddressKind::Orchard(data) => T::from_orchard(self.net, data), + AddressKind::P2pkh(data) => T::from_transparent_p2pkh(self.net, data), + AddressKind::P2sh(data) => T::from_transparent_p2sh(self.net, data), + } + } }