]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Do not return a reference to a u64 in rust-lightning-invoices
authorMatt Corallo <git@bluematt.me>
Fri, 23 Apr 2021 00:25:55 +0000 (00:25 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 29 Apr 2021 15:48:16 +0000 (15:48 +0000)
There is generally never a reason to return a non-mutable reference
to a u64 vs just copying it, same applies here. It makes the API
slightly less consistent, but is easier to map in bindings and just
makes more sense.

lightning-invoice/src/lib.rs

index 3d75d4d65dc057c148d11886ae03a702da9205ea..5a9c094c63be6d1190249df462a4bd4c3a794154 100644 (file)
@@ -1029,8 +1029,8 @@ impl Invoice {
        }
 
        /// Returns the invoice's `min_cltv_expiry` time if present
-       pub fn min_final_cltv_expiry(&self) -> Option<&u64> {
-               self.signed_invoice.min_final_cltv_expiry().map(|x| &x.0)
+       pub fn min_final_cltv_expiry(&self) -> Option<u64> {
+               self.signed_invoice.min_final_cltv_expiry().map(|x| x.0)
        }
 
        /// Returns a list of all fallback addresses
@@ -1591,7 +1591,7 @@ mod test {
                );
                assert_eq!(invoice.payee_pub_key(), Some(&public_key));
                assert_eq!(invoice.expiry_time(), Duration::from_secs(54321));
-               assert_eq!(invoice.min_final_cltv_expiry(), Some(&144));
+               assert_eq!(invoice.min_final_cltv_expiry(), Some(144));
                assert_eq!(invoice.fallbacks(), vec![&Fallback::PubKeyHash([0;20])]);
                assert_eq!(invoice.routes(), vec![&RouteHint(route_1), &RouteHint(route_2)]);
                assert_eq!(