Skip to content

Commit fe50a50

Browse files
committed
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."
1 parent bf3bc42 commit fe50a50

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lightning/src/ln/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ impl core::fmt::Display for PaymentPreimage {
112112
}
113113

114114
/// Converts a `PaymentPreimage` into a `PaymentHash` by hashing the preimage with SHA256.
115-
impl Into<PaymentHash> for PaymentPreimage {
116-
fn into(self) -> PaymentHash {
117-
PaymentHash(Sha256::hash(&self.0).to_byte_array())
115+
impl From<PaymentPreimage> for PaymentHash {
116+
fn from(value: PaymentPreimage) -> Self {
117+
PaymentHash(Sha256::hash(&value.0).to_byte_array())
118118
}
119119
}
120120

0 commit comments

Comments
 (0)