Merge rust-bitcoin/rust-bitcoin#3831: units: Don't ignore serde examples

0e5d6db7df units: Don't ignore serde examples (Tobin C. Harding)

Pull request description:

  There is no reason to ignore the rustdoc example in `units::amount::serde`. The `as_btc` function requires the `alloc` features so use `as_sat` in the example instead.

  While we are at it clean up the whole block of rustdocs.

ACKs for top commit:
  apoelstra:
    ACK 0e5d6db7df9a1f9b4e9180d49cf1532551570e33; successfully ran local tests

Tree-SHA512: d108779faa8baf5c8a1cb533e44e8ac209e3e1001eb8ec8ae1f9ba9b0cf5f8c45c38df77e15193cdc990fcd0fbf48bca489aadbd196c6323560040b7fd043332
This commit is contained in:
merge-script 2025-01-07 15:21:26 +00:00
commit 4ade08c755
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 7 additions and 6 deletions

View File

@ -3,19 +3,20 @@
// methods are implementation of a standardized serde-specific signature
#![allow(missing_docs)]
//! This module adds serde serialization and deserialization support for Amounts.
//! This module adds serde serialization and deserialization support for amounts.
//!
//! Since there is not a default way to serialize and deserialize Amounts, multiple
//! ways are supported and it's up to the user to decide which serialiation to use.
//! The provided modules can be used as follows:
//! Since there is not a default way to serialize and deserialize amounts, multiple
//! ways are supported and it's up to the user to decide which serialization to use.
//!
//! ```rust,ignore
//! # Examples
//!
//! ```
//! use serde::{Serialize, Deserialize};
//! use bitcoin_units::Amount;
//!
//! #[derive(Serialize, Deserialize)]
//! pub struct HasAmount {
//! #[serde(with = "bitcoin_units::amount::serde::as_btc")]
//! #[serde(with = "bitcoin_units::amount::serde::as_sat")]
//! pub amount: Amount,
//! }
//! ```