mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 07:17:40 +01:00
Prefer implementing From
over Into
.. as the std library docs state that implementing Into should be avoided: "One should avoid implementing Into and implement From instead. Implementing From automatically provides one with an implementation of Into thanks to the blanket implementation in the standard library."
This commit is contained in:
parent
bf3bc420c7
commit
fe50a507ab
1 changed files with 3 additions and 3 deletions
|
@ -112,9 +112,9 @@ impl core::fmt::Display for PaymentPreimage {
|
|||
}
|
||||
|
||||
/// Converts a `PaymentPreimage` into a `PaymentHash` by hashing the preimage with SHA256.
|
||||
impl Into<PaymentHash> for PaymentPreimage {
|
||||
fn into(self) -> PaymentHash {
|
||||
PaymentHash(Sha256::hash(&self.0).to_byte_array())
|
||||
impl From<PaymentPreimage> for PaymentHash {
|
||||
fn from(value: PaymentPreimage) -> Self {
|
||||
PaymentHash(Sha256::hash(&value.0).to_byte_array())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue