From fe50a507ab2840216584a197f63d412b2fb34834 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Fri, 1 Mar 2024 11:42:54 +0100 Subject: [PATCH] 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." --- lightning/src/ln/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lightning/src/ln/mod.rs b/lightning/src/ln/mod.rs index bf2e94caa..71b73390d 100644 --- a/lightning/src/ln/mod.rs +++ b/lightning/src/ln/mod.rs @@ -112,9 +112,9 @@ impl core::fmt::Display for PaymentPreimage { } /// Converts a `PaymentPreimage` into a `PaymentHash` by hashing the preimage with SHA256. -impl Into for PaymentPreimage { - fn into(self) -> PaymentHash { - PaymentHash(Sha256::hash(&self.0).to_byte_array()) +impl From for PaymentHash { + fn from(value: PaymentPreimage) -> Self { + PaymentHash(Sha256::hash(&value.0).to_byte_array()) } } -- 2.39.5