]> Untitled Git - bdk/commitdiff
Use `default: D` mirroring Rust documentation
authorTobin Harding <me@tobin.cc>
Thu, 6 May 2021 03:54:52 +0000 (13:54 +1000)
committerTobin Harding <me@tobin.cc>
Thu, 6 May 2021 23:08:49 +0000 (09:08 +1000)
Currently we use `F: f` for the argument that is the default function
passed to `map_or_else` and pass a closure for the second argument. This
bent my brain while reading the documentation because the docs use
`default: D` for the first and `f: F` for the second. Although this is
totally trivial it makes deciphering the combinator chain easier if we
name the arguments the same way the Rust docs do.

Use `default: D` for the identifier of the default function passed into `map_or_else`.

src/database/mod.rs

index 6955111fcde83585941c899afe33f3cab084d644..84eb511e1b219d6e6d4dbebf2a980dd3a39dd18a 100644 (file)
@@ -164,14 +164,14 @@ pub(crate) trait DatabaseUtils: Database {
             .map(|o| o.is_some())
     }
 
-    fn get_raw_tx_or<F>(&self, txid: &Txid, f: F) -> Result<Option<Transaction>, Error>
+    fn get_raw_tx_or<D>(&self, txid: &Txid, default: D) -> Result<Option<Transaction>, Error>
     where
-        F: FnOnce() -> Result<Option<Transaction>, Error>,
+        D: FnOnce() -> Result<Option<Transaction>, Error>,
     {
         self.get_tx(txid, true)?
             .map(|t| t.transaction)
             .flatten()
-            .map_or_else(f, |t| Ok(Some(t)))
+            .map_or_else(default, |t| Ok(Some(t)))
     }
 
     fn get_previous_output(&self, outpoint: &OutPoint) -> Result<Option<TxOut>, Error> {