Skip to content

Commit 50d59d6

Browse files
committed
Merge #176: Fix feature gating
1f773b9 Feature gate the segwit::EncodeError (Tobin C. Harding) 9aca6a9 Remove links to feature gated functions (Tobin C. Harding) Pull request description: We have feature gate issues in docs and with an unused error type. I don't have a good way of including links that are feature build specific in rustdocs so I just used plain old back ticks. ACKs for top commit: apoelstra: ACK 1f773b9 Tree-SHA512: b2fe813da0c8957b2ce30253ce625e4bb088a56655fc27987d324bb977a6e251ca00fb277cc341b2ba6526b6d4b4b8e0b9dd666068e9c3300e667a349f38f5d7
2 parents 091187e + 1f773b9 commit 50d59d6

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//!
1414
//! - If you are doing segwit stuff you likely want to use the [`segwit`] API.
1515
//! - Non-segwit stuff and you have an allocator, use the top level API. For normal usage the
16-
//! [`encode`] and [`decode`] functions should suffice. There are also various other functions for
16+
//! `encode` and `decode` functions should suffice. There are also various other functions for
1717
//! explicit control of the checksum algorithm and the case used when encoding.
1818
//! - Non-segwit stuff and you do *not* have an allocator, use the [`CheckedHrpstring`] type for
1919
//! decoding. For encoding we provide various top level functions of the form `encode*_to_fmt`.

src/primitives/hrp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl Hrp {
221221
/// Displays the human-readable part.
222222
///
223223
/// If an uppercase HRP was parsed during object construction then the returned string will be
224-
/// in uppercase also. For a lowercase string see [`Self::to_lowercase`].
224+
/// in uppercase also. For a lowercase string see `Self::to_lowercase`.
225225
impl fmt::Display for Hrp {
226226
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
227227
for c in self.char_iter() {

src/segwit.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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")]
377378
pub 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")]
388390
impl 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")]
402405
impl 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")]
415419
impl From<InvalidWitnessVersionError> for EncodeError {
416420
#[inline]
417421
fn from(e: InvalidWitnessVersionError) -> Self { Self::WitnessVersion(e) }
418422
}
419423

424+
#[cfg(feature = "alloc")]
420425
impl From<WitnessLengthError> for EncodeError {
421426
#[inline]
422427
fn from(e: WitnessLengthError) -> Self { Self::WitnessLength(e) }
423428
}
424429

430+
#[cfg(feature = "alloc")]
425431
impl From<SegwitCodeLengthError> for EncodeError {
426432
#[inline]
427433
fn from(e: SegwitCodeLengthError) -> Self { Self::TooLong(e) }
428434
}
429435

436+
#[cfg(feature = "alloc")]
430437
impl From<fmt::Error> for EncodeError {
431438
#[inline]
432439
fn from(e: fmt::Error) -> Self { Self::Fmt(e) }

0 commit comments

Comments
 (0)