Standardize function doc Safety, Returns and Parameters

Changed the function docs to have the same format of
///
/// # Safety
///
/// description
This commit is contained in:
jamil.lambert 2024-05-23 12:28:24 +01:00
parent df83016c98
commit 11bb1ff6ff
5 changed files with 12 additions and 2 deletions

View File

@ -46,7 +46,7 @@ mod primitive {
impl PushBytes { impl PushBytes {
/// Creates `&Self` without checking the length. /// Creates `&Self` without checking the length.
/// ///
/// ## Safety /// # Safety
/// ///
/// The caller is responsible for checking that the length is less than the [`LIMIT`]. /// The caller is responsible for checking that the length is less than the [`LIMIT`].
unsafe fn from_slice_unchecked(bytes: &[u8]) -> &Self { unsafe fn from_slice_unchecked(bytes: &[u8]) -> &Self {
@ -55,7 +55,7 @@ mod primitive {
/// Creates `&mut Self` without checking the length. /// Creates `&mut Self` without checking the length.
/// ///
/// ## Safety /// # Safety
/// ///
/// The caller is responsible for checking that the length is less than the [`LIMIT`]. /// The caller is responsible for checking that the length is less than the [`LIMIT`].
unsafe fn from_mut_slice_unchecked(bytes: &mut [u8]) -> &mut Self { unsafe fn from_mut_slice_unchecked(bytes: &mut [u8]) -> &mut Self {

View File

@ -21,6 +21,7 @@ use crate::consensus::encode;
/// [`bitcoinconsensus::VERIFY_ALL`]. /// [`bitcoinconsensus::VERIFY_ALL`].
/// ///
/// # Parameters /// # Parameters
///
/// * `index` - The input index in spending which is spending this transaction. /// * `index` - The input index in spending which is spending this transaction.
/// * `amount` - The amount this script guards. /// * `amount` - The amount this script guards.
/// * `spending_tx` - The transaction that attempts to spend the output holding this script. /// * `spending_tx` - The transaction that attempts to spend the output holding this script.
@ -38,6 +39,7 @@ pub fn verify_script(
/// Verifies spend of an input script. /// Verifies spend of an input script.
/// ///
/// # Parameters /// # Parameters
///
/// * `index` - The input index in spending which is spending this transaction. /// * `index` - The input index in spending which is spending this transaction.
/// * `amount` - The amount this script guards. /// * `amount` - The amount this script guards.
/// * `spending_tx` - The transaction that attempts to spend the output holding this script. /// * `spending_tx` - The transaction that attempts to spend the output holding this script.
@ -112,6 +114,7 @@ impl Script {
/// Shorthand for [`Self::verify_with_flags`] with flag [`bitcoinconsensus::VERIFY_ALL`]. /// Shorthand for [`Self::verify_with_flags`] with flag [`bitcoinconsensus::VERIFY_ALL`].
/// ///
/// # Parameters /// # Parameters
///
/// * `index` - The input index in spending which is spending this transaction. /// * `index` - The input index in spending which is spending this transaction.
/// * `amount` - The amount this script guards. /// * `amount` - The amount this script guards.
/// * `spending_tx` - The transaction that attempts to spend the output holding this script. /// * `spending_tx` - The transaction that attempts to spend the output holding this script.
@ -129,6 +132,7 @@ impl Script {
/// Verifies spend of an input script. /// Verifies spend of an input script.
/// ///
/// # Parameters /// # Parameters
///
/// * `index` - The input index in spending which is spending this transaction. /// * `index` - The input index in spending which is spending this transaction.
/// * `amount` - The amount this script guards. /// * `amount` - The amount this script guards.
/// * `spending_tx` - The transaction that attempts to spend the output holding this script. /// * `spending_tx` - The transaction that attempts to spend the output holding this script.

View File

@ -747,6 +747,7 @@ pub trait TapTweak {
/// * G is the generator point /// * G is the generator point
/// ///
/// # Returns /// # Returns
///
/// The tweaked key and its parity. /// The tweaked key and its parity.
fn tap_tweak<C: Verification>( fn tap_tweak<C: Verification>(
self, self,
@ -776,6 +777,7 @@ impl TapTweak for UntweakedPublicKey {
/// * G is the generator point /// * G is the generator point
/// ///
/// # Returns /// # Returns
///
/// The tweaked key and its parity. /// The tweaked key and its parity.
fn tap_tweak<C: Verification>( fn tap_tweak<C: Verification>(
self, self,
@ -807,6 +809,7 @@ impl TapTweak for UntweakedKeypair {
/// The public key is generated from a private key by multiplying with generator point, Q = qG. /// The public key is generated from a private key by multiplying with generator point, Q = qG.
/// ///
/// # Returns /// # Returns
///
/// The tweaked key and its parity. /// The tweaked key and its parity.
fn tap_tweak<C: Verification>( fn tap_tweak<C: Verification>(
self, self,

View File

@ -35,6 +35,7 @@ pub use self::block::{MerkleBlock, MerkleBlockError, PartialMerkleTree};
/// this method and should not be used again afterwards). /// this method and should not be used again afterwards).
/// ///
/// # Returns /// # Returns
///
/// - `None` if `hashes` is empty. The merkle root of an empty tree of hashes is undefined. /// - `None` if `hashes` is empty. The merkle root of an empty tree of hashes is undefined.
/// - `Some(hash)` if `hashes` contains one element. A single hash is by definition the merkle root. /// - `Some(hash)` if `hashes` contains one element. A single hash is by definition the merkle root.
/// - `Some(merkle_root)` if length of `hashes` is greater than one. /// - `Some(merkle_root)` if length of `hashes` is greater than one.
@ -53,6 +54,7 @@ where
/// Calculates the merkle root of an iterator of *hashes*. /// Calculates the merkle root of an iterator of *hashes*.
/// ///
/// # Returns /// # Returns
///
/// - `None` if `hashes` is empty. The merkle root of an empty tree of hashes is undefined. /// - `None` if `hashes` is empty. The merkle root of an empty tree of hashes is undefined.
/// - `Some(hash)` if `hashes` contains one element. A single hash is by definition the merkle root. /// - `Some(hash)` if `hashes` contains one element. A single hash is by definition the merkle root.
/// - `Some(merkle_root)` if length of `hashes` is greater than one. /// - `Some(merkle_root)` if length of `hashes` is greater than one.

View File

@ -739,6 +739,7 @@ pub trait GetKey {
/// Attempts to get the private key for `key_request`. /// Attempts to get the private key for `key_request`.
/// ///
/// # Returns /// # Returns
///
/// - `Some(key)` if the key is found. /// - `Some(key)` if the key is found.
/// - `None` if the key was not found but no error was encountered. /// - `None` if the key was not found but no error was encountered.
/// - `Err` if an error was encountered while looking for the key. /// - `Err` if an error was encountered while looking for the key.