@@ -44,8 +44,6 @@ pub use crate::primitives::{Bech32, Bech32m};
4444mod error;
4545pub mod primitives;
4646
47- #[ cfg( feature = "arrayvec" ) ]
48- use arrayvec:: { ArrayVec , CapacityError } ;
4947pub use primitives:: gf32:: Fe32 as u5;
5048
5149/// Interface to write `u5`s into a sink.
@@ -164,21 +162,6 @@ pub trait FromBase32: Sized {
164162
165163macro_rules! write_base_n {
166164 { $tr: ident, $ty: ident, $meth: ident } => {
167- #[ cfg( feature = "arrayvec" ) ]
168- impl <const L : usize > $tr for ArrayVec <$ty, L > {
169- type Error = CapacityError ;
170-
171- fn write( & mut self , data: & [ $ty] ) -> Result <( ) , Self :: Error > {
172- self . try_extend_from_slice( data) ?;
173- Ok ( ( ) )
174- }
175-
176- fn $meth( & mut self , data: $ty) -> Result <( ) , Self :: Error > {
177- self . push( data) ;
178- Ok ( ( ) )
179- }
180- }
181-
182165 #[ cfg( feature = "alloc" ) ]
183166 impl $tr for Vec <$ty> {
184167 type Error = Infallible ;
@@ -199,41 +182,6 @@ macro_rules! write_base_n {
199182write_base_n ! { WriteBase32 , u5, write_u5 }
200183write_base_n ! { WriteBase256 , u8 , write_u8 }
201184
202- #[ cfg( feature = "arrayvec" ) ]
203- #[ derive( Clone , Debug , PartialEq , Eq ) ]
204- /// Combination of Errors for use with array vec
205- pub enum ComboError {
206- /// Error from this crate
207- Bech32Error ( Error ) ,
208- /// Error from `arrayvec`.
209- WriteError ( CapacityError ) ,
210- }
211- #[ cfg( feature = "arrayvec" ) ]
212- impl From < Error > for ComboError {
213- fn from ( e : Error ) -> ComboError { ComboError :: Bech32Error ( e) }
214- }
215- #[ cfg( feature = "arrayvec" ) ]
216- impl From < CapacityError > for ComboError {
217- fn from ( e : CapacityError ) -> ComboError { ComboError :: WriteError ( e) }
218- }
219- #[ cfg( feature = "arrayvec" ) ]
220- impl From < hrp:: Error > for ComboError {
221- fn from ( e : hrp:: Error ) -> ComboError { ComboError :: Bech32Error ( Error :: Hrp ( e) ) }
222- }
223-
224- #[ cfg( feature = "arrayvec" ) ]
225- impl < const L : usize > FromBase32 for ArrayVec < u8 , L > {
226- type Error = ComboError ;
227-
228- /// Convert base32 to base256, removes null-padding if present, returns
229- /// `Err(Error::InvalidPadding)` if padding bits are unequal `0`
230- fn from_base32 ( b32 : & [ u5 ] ) -> Result < Self , Self :: Error > {
231- let mut ret: ArrayVec < u8 , L > = ArrayVec :: new ( ) ;
232- convert_bits_in :: < ComboError , _ , _ > ( b32, 5 , 8 , false , & mut ret) ?;
233- Ok ( ret)
234- }
235- }
236-
237185#[ cfg( feature = "alloc" ) ]
238186impl FromBase32 for Vec < u8 > {
239187 type Error = Error ;
@@ -861,9 +809,6 @@ where
861809
862810#[ cfg( test) ]
863811mod tests {
864- #[ cfg( feature = "arrayvec" ) ]
865- use arrayvec:: ArrayString ;
866-
867812 use super :: * ;
868813
869814 #[ cfg( feature = "alloc" ) ]
@@ -1164,33 +1109,6 @@ mod tests {
11641109 assert ! ( u5:: try_from( 32_u128 ) . is_err( ) ) ;
11651110 }
11661111
1167- #[ test]
1168- #[ cfg( feature = "arrayvec" ) ]
1169- fn test_arrayvec ( ) {
1170- let mut encoded = ArrayString :: < 30 > :: new ( ) ;
1171-
1172- let mut base32 = ArrayVec :: < u5 , 30 > :: new ( ) ;
1173-
1174- [ 0x00u8 , 0x01 , 0x02 ] . write_base32 ( & mut base32) . unwrap ( ) ;
1175-
1176- let bech32_hrp = Hrp :: parse ( "bech32" ) . expect ( "bech32 is valid" ) ;
1177- encode_to_fmt_anycase ( & mut encoded, bech32_hrp, & base32, Variant :: Bech32 ) . unwrap ( ) . unwrap ( ) ;
1178- assert_eq ! ( & * encoded, "bech321qqqsyrhqy2a" ) ;
1179-
1180- println ! ( "{}" , encoded) ;
1181-
1182- let mut decoded = ArrayVec :: < u5 , 30 > :: new ( ) ;
1183-
1184- let mut scratch = ArrayVec :: < u5 , 30 > :: new ( ) ;
1185-
1186- let ( hrp, data, variant) =
1187- decode_lowercase :: < ComboError , _ , _ > ( & encoded, & mut decoded, & mut scratch) . unwrap ( ) ;
1188- assert_eq ! ( hrp. to_string( ) , "bech32" ) ;
1189- let res = ArrayVec :: < u8 , 30 > :: from_base32 ( data) . unwrap ( ) ;
1190- assert_eq ! ( & res, [ 0x00 , 0x01 , 0x02 ] . as_ref( ) ) ;
1191- assert_eq ! ( variant, Variant :: Bech32 ) ;
1192- }
1193-
11941112 #[ test]
11951113 #[ cfg( feature = "alloc" ) ]
11961114 fn decode_bitcoin_bech32_address ( ) {
0 commit comments