Standardize function doc Examples

Changed the function docs to have the same format of
///
/// # Examples
///
/// description
This commit is contained in:
jamil.lambert 2024-05-23 11:38:32 +01:00
parent 233a9133d8
commit d219ceb68e
6 changed files with 13 additions and 1 deletions

View File

@ -480,6 +480,7 @@ impl<'a, R: BufRead + ?Sized> BitStreamReader<'a, R> {
/// Reads nbit bits, returning the bits in a `u64` starting with the rightmost bit.
///
/// # Examples
///
/// ```
/// # use bitcoin::bip158::BitStreamReader;
/// # let data = vec![0xff];

View File

@ -45,6 +45,7 @@ pub use units::locktime::absolute::{
/// * [BIP-113 Median time-past as endpoint for lock-time calculations](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki)
///
/// # Examples
///
/// ```
/// # use bitcoin::absolute::{LockTime, LockTime::*};
/// # let n = LockTime::from_consensus(741521); // n OP_CHECKLOCKTIMEVERIFY
@ -61,6 +62,7 @@ pub enum LockTime {
/// A block height lock time value.
///
/// # Examples
///
/// ```rust
/// use bitcoin::absolute::LockTime;
///
@ -73,6 +75,7 @@ pub enum LockTime {
/// A UNIX timestamp lock time value.
///
/// # Examples
///
/// ```rust
/// use bitcoin::absolute::LockTime;
///
@ -141,6 +144,7 @@ impl LockTime {
/// See [`LOCK_TIME_THRESHOLD`] for definition of a valid height value.
///
/// # Examples
///
/// ```rust
/// # use bitcoin::absolute::LockTime;
/// assert!(LockTime::from_height(741521).is_ok());
@ -157,6 +161,7 @@ impl LockTime {
/// See [`LOCK_TIME_THRESHOLD`] for definition of a valid time value.
///
/// # Examples
///
/// ```rust
/// # use bitcoin::absolute::LockTime;
/// assert!(LockTime::from_time(1653195600).is_ok());
@ -196,6 +201,7 @@ impl LockTime {
/// `height`/`time` is valid.
///
/// # Examples
///
/// ```no_run
/// # use bitcoin::absolute::{LockTime, Height, Time};
/// // Can be implemented if block chain data is available.

View File

@ -710,6 +710,7 @@ pub type UntweakedKeypair = Keypair;
/// Tweaked BIP-340 key pair
///
/// # Examples
///
/// ```
/// # #[cfg(feature = "rand-std")] {
/// # use bitcoin::key::{Keypair, TweakedKeypair, TweakedPublicKey};

View File

@ -122,7 +122,7 @@ macro_rules! const_assert {
///
/// Note: Paths are not supported (for ex. impl_from_infallible!(Hello<D: std::fmt::Display>).
///
/// ## Examples
/// # Examples
///
/// ```rust
/// # use core::fmt::{Display, Debug};

View File

@ -21,6 +21,7 @@ use internals::write_err;
/// A set of denominations in which amounts can be expressed.
///
/// # Examples
///
/// ```
/// # use core::str::FromStr;
/// # use bitcoin_units::Amount;
@ -939,6 +940,7 @@ impl Amount {
/// Please be aware of the risk of using floating-point numbers.
///
/// # Examples
///
/// ```
/// # use bitcoin_units::amount::{Amount, Denomination};
/// let amount = Amount::from_sat(100_000);

View File

@ -51,6 +51,7 @@ impl Height {
/// If `n` does not represent a valid block height value.
///
/// # Examples
///
/// ```rust
/// use bitcoin_units::locktime::absolute::Height;
///
@ -146,6 +147,7 @@ impl Time {
/// If `n` does not encode a valid UNIX time stamp.
///
/// # Examples
///
/// ```rust
/// use bitcoin_units::locktime::absolute::Time;
///