From: Elias Rohrer Date: Fri, 1 Mar 2024 10:42:54 +0000 (+0100) Subject: Prefer implementing `From` over `Into` X-Git-Tag: v0.0.123-beta~51^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=fe50a507ab2840216584a197f63d412b2fb34834;p=rust-lightning 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." --- 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()) } }