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.
This commit is contained in:
Tobin Harding 2021-11-19 09:37:34 +11:00
parent 804a38cb67
commit 822c99222d
1 changed files with 16 additions and 10 deletions

View File

@ -418,8 +418,9 @@ pub struct Address {
serde_string_impl!(Address, "a Bitcoin address"); serde_string_impl!(Address, "a Bitcoin address");
impl Address { impl Address {
/// Constructs a pay to (compressed) public key hash address from a public key. This is the /// Creates a pay to (compressed) public key hash address from a public key.
/// preferred non-witness type address. ///
/// This is the preferred non-witness type address.
#[inline] #[inline]
pub fn p2pkh(pk: &ecdsa::PublicKey, network: Network) -> Address { pub fn p2pkh(pk: &ecdsa::PublicKey, network: Network) -> Address {
let mut hash_engine = PubkeyHash::engine(); let mut hash_engine = PubkeyHash::engine();
@ -431,8 +432,10 @@ impl Address {
} }
} }
/// Creates a pay to script hash P2SH address from a script. This address type was introduced /// Creates a pay to script hash P2SH address from a script.
/// with BIP16 and is the popular type to implement multi-sig these days. ///
/// This address type was introduced with BIP16 and is the popular type to implement multi-sig
/// these days.
#[inline] #[inline]
pub fn p2sh(script: &script::Script, network: Network) -> Result<Address, Error> { pub fn p2sh(script: &script::Script, network: Network) -> Result<Address, Error> {
if script.len() > MAX_SCRIPT_ELEMENT_SIZE{ if script.len() > MAX_SCRIPT_ELEMENT_SIZE{
@ -444,8 +447,9 @@ impl Address {
}) })
} }
/// Creates a witness pay to public key address from a public key. This is the native segwit /// Creates a witness pay to public key address from a public key.
/// address type for an output redeemable with a single signature. ///
/// This is the native segwit address type for an output redeemable with a single signature.
/// ///
/// # Errors /// # Errors
/// Will only return an error if an uncompressed public key is provided. /// Will only return an error if an uncompressed public key is provided.
@ -466,8 +470,9 @@ impl Address {
}) })
} }
/// Creates a pay to script address that embeds a witness pay to public key. This is a segwit /// Creates a pay to script address that embeds a witness pay to public key.
/// address type that looks familiar (as p2sh) to legacy clients. ///
/// This is a segwit address type that looks familiar (as p2sh) to legacy clients.
/// ///
/// # Errors /// # Errors
/// Will only return an Error if an uncompressed public key is provided. /// Will only return an Error if an uncompressed public key is provided.
@ -500,8 +505,9 @@ impl Address {
} }
} }
/// Creates a pay to script address that embeds a witness pay to script hash address. This is a /// Creates a pay to script address that embeds a witness pay to script hash address.
/// segwit address type that looks familiar (as p2sh) to legacy clients. ///
/// This is a segwit address type that looks familiar (as p2sh) to legacy clients.
pub fn p2shwsh(script: &script::Script, network: Network) -> Address { pub fn p2shwsh(script: &script::Script, network: Network) -> Address {
let ws = script::Builder::new() let ws = script::Builder::new()
.push_int(0) .push_int(0)