Rename as_u32 -> to_u32

Rust naming conventions stipulate that conversion methods from owned ->
owned for `Copy` types use the naming convention `to_`.

This change makes the function name objectively better, however it makes
no claims of being the 'best' name. We have had much discussion on using
`to_standard` vs `to_u32` but are unable to reach consensus.
This commit is contained in:
Tobin Harding 2022-02-22 18:02:37 +00:00
parent 2bd71c3748
commit d1753d7ff1
2 changed files with 5 additions and 3 deletions

View File

@ -855,8 +855,10 @@ impl EcdsaSigHashType {
}
}
/// Converts to a u32
pub fn as_u32(self) -> u32 { self as u32 }
/// Converts [`EcdsaSigHashType`] to a `u32` sighash flag.
///
/// The returned value is guaranteed to be a valid according to standardness rules.
pub fn to_u32(self) -> u32 { self as u32 }
}
/// Error returned when parsing `SigHashType` fails.

View File

@ -600,7 +600,7 @@ impl<R: Deref<Target=Transaction>> SigHashCache<R> {
}
self.tx.lock_time.consensus_encode(&mut writer)?;
sighash_type.as_u32().consensus_encode(&mut writer)?;
sighash_type.to_u32().consensus_encode(&mut writer)?;
Ok(())
}