Skip to content

Commit 822c992

Browse files
committed
Improve constructor rustdocs for Address
Improve the rustdocs for the various `Address` constructors by putting the brief description on a separate line with further description in its own paragraph. This is the layout best practice for function documentation using rustdocs. Also, favour 'creates' over 'constructs' because it is more common in the docs of this struct.
1 parent 804a38c commit 822c992

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

src/util/address.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,9 @@ pub struct Address {
418418
serde_string_impl!(Address, "a Bitcoin address");
419419

420420
impl Address {
421-
/// Constructs a pay to (compressed) public key hash address from a public key. This is the
422-
/// preferred non-witness type address.
421+
/// Creates a pay to (compressed) public key hash address from a public key.
422+
///
423+
/// This is the preferred non-witness type address.
423424
#[inline]
424425
pub fn p2pkh(pk: &ecdsa::PublicKey, network: Network) -> Address {
425426
let mut hash_engine = PubkeyHash::engine();
@@ -431,8 +432,10 @@ impl Address {
431432
}
432433
}
433434

434-
/// Creates a pay to script hash P2SH address from a script. This address type was introduced
435-
/// with BIP16 and is the popular type to implement multi-sig these days.
435+
/// Creates a pay to script hash P2SH address from a script.
436+
///
437+
/// This address type was introduced with BIP16 and is the popular type to implement multi-sig
438+
/// these days.
436439
#[inline]
437440
pub fn p2sh(script: &script::Script, network: Network) -> Result<Address, Error> {
438441
if script.len() > MAX_SCRIPT_ELEMENT_SIZE{
@@ -444,8 +447,9 @@ impl Address {
444447
})
445448
}
446449

447-
/// Creates a witness pay to public key address from a public key. This is the native segwit
448-
/// address type for an output redeemable with a single signature.
450+
/// Creates a witness pay to public key address from a public key.
451+
///
452+
/// This is the native segwit address type for an output redeemable with a single signature.
449453
///
450454
/// # Errors
451455
/// Will only return an error if an uncompressed public key is provided.
@@ -466,8 +470,9 @@ impl Address {
466470
})
467471
}
468472

469-
/// Creates a pay to script address that embeds a witness pay to public key. This is a segwit
470-
/// address type that looks familiar (as p2sh) to legacy clients.
473+
/// Creates a pay to script address that embeds a witness pay to public key.
474+
///
475+
/// This is a segwit address type that looks familiar (as p2sh) to legacy clients.
471476
///
472477
/// # Errors
473478
/// Will only return an Error if an uncompressed public key is provided.
@@ -500,8 +505,9 @@ impl Address {
500505
}
501506
}
502507

503-
/// Creates a pay to script address that embeds a witness pay to script hash address. This is a
504-
/// segwit address type that looks familiar (as p2sh) to legacy clients.
508+
/// Creates a pay to script address that embeds a witness pay to script hash address.
509+
///
510+
/// This is a segwit address type that looks familiar (as p2sh) to legacy clients.
505511
pub fn p2shwsh(script: &script::Script, network: Network) -> Address {
506512
let ws = script::Builder::new()
507513
.push_int(0)

0 commit comments

Comments
 (0)