@@ -374,6 +374,7 @@ impl From<SegwitHrpstringError> for DecodeError {
374374/// An error while constructing a [`SegwitHrpstring`] type.
375375#[ derive( Debug , Clone , PartialEq , Eq ) ]
376376#[ non_exhaustive]
377+ #[ cfg( feature = "alloc" ) ]
377378pub enum EncodeError {
378379 /// Invalid witness version (must be 0-16 inclusive).
379380 WitnessVersion ( InvalidWitnessVersionError ) ,
@@ -385,6 +386,7 @@ pub enum EncodeError {
385386 Fmt ( fmt:: Error ) ,
386387}
387388
389+ #[ cfg( feature = "alloc" ) ]
388390impl fmt:: Display for EncodeError {
389391 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
390392 use EncodeError :: * ;
@@ -399,6 +401,7 @@ impl fmt::Display for EncodeError {
399401}
400402
401403#[ cfg( feature = "std" ) ]
404+ #[ cfg( feature = "alloc" ) ]
402405impl std:: error:: Error for EncodeError {
403406 fn source ( & self ) -> Option < & ( dyn std:: error:: Error + ' static ) > {
404407 use EncodeError :: * ;
@@ -412,21 +415,25 @@ impl std::error::Error for EncodeError {
412415 }
413416}
414417
418+ #[ cfg( feature = "alloc" ) ]
415419impl From < InvalidWitnessVersionError > for EncodeError {
416420 #[ inline]
417421 fn from ( e : InvalidWitnessVersionError ) -> Self { Self :: WitnessVersion ( e) }
418422}
419423
424+ #[ cfg( feature = "alloc" ) ]
420425impl From < WitnessLengthError > for EncodeError {
421426 #[ inline]
422427 fn from ( e : WitnessLengthError ) -> Self { Self :: WitnessLength ( e) }
423428}
424429
430+ #[ cfg( feature = "alloc" ) ]
425431impl From < SegwitCodeLengthError > for EncodeError {
426432 #[ inline]
427433 fn from ( e : SegwitCodeLengthError ) -> Self { Self :: TooLong ( e) }
428434}
429435
436+ #[ cfg( feature = "alloc" ) ]
430437impl From < fmt:: Error > for EncodeError {
431438 #[ inline]
432439 fn from ( e : fmt:: Error ) -> Self { Self :: Fmt ( e) }
0 commit comments