From 175a4ad104241e0ef22b9b4803863e746cd0c694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ceyhun=20=C5=9Een?= Date: Wed, 26 Jun 2024 14:05:55 +0300 Subject: [PATCH] macros: Don't use late initializator for get_item!, use let in macro. --- src/ledger/macros.rs | 8 ++------ src/ledger/transactions.rs | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/ledger/macros.rs b/src/ledger/macros.rs index 060d5d0..75fa954 100644 --- a/src/ledger/macros.rs +++ b/src/ledger/macros.rs @@ -50,8 +50,8 @@ macro_rules! update_item { /// Assigns an item from member to given assignee, which is guarded by a `Cell`. #[macro_export] macro_rules! get_item { - ($member:expr, $assignee:expr) => { - $assignee = $member.take(); + ($member:expr, $assignee:ident) => { + let $assignee = $member.take(); $member.set($assignee.clone()); }; } @@ -71,7 +71,6 @@ mod tests { fn add_get_item_to_vec() { let strct = Test::default(); - let mut items: Vec; get_item!(strct.vec_member_1, items); assert_eq!(items.len(), 0); @@ -86,7 +85,6 @@ mod tests { fn update_member() { let strct = Test::default(); - let mut item: isize; get_item!(strct.int_member_1, item); assert_eq!(item, isize::default()); @@ -103,8 +101,6 @@ mod tests { fn remove_item_from_vec() { let strct = Test::default(); - let mut items: Vec; - add_item_to_vec!(strct.vec_member_1, 0x45); add_item_to_vec!(strct.vec_member_1, 0x1F); add_item_to_vec!(strct.vec_member_1, 0x100); diff --git a/src/ledger/transactions.rs b/src/ledger/transactions.rs index 03ec7d4..ce8c89b 100644 --- a/src/ledger/transactions.rs +++ b/src/ledger/transactions.rs @@ -1,7 +1,7 @@ //! # Transaction Related Ledger Operations use super::{errors::LedgerError, Ledger}; -use crate::{add_item_to_vec, get_item, ledger::address::UserCredential, return_vec_item}; +use crate::{add_item_to_vec, get_item, return_vec_item}; use bitcoin::{absolute, Amount, OutPoint, ScriptBuf, Transaction, TxIn, TxOut, Txid, Witness}; impl Ledger { @@ -49,7 +49,6 @@ impl Ledger { } /// Returns a transaction which matches the given txid. pub fn get_transaction(&self, txid: Txid) -> Result { - let txs: Vec; get_item!(self.transactions, txs); let tx = txs @@ -121,7 +120,6 @@ impl Ledger { /// Creates a `TxIn` with some defaults. pub fn create_txin(&self, txid: Txid, vout: u32) -> TxIn { - let credentials: Vec; get_item!(self.credentials, credentials); let witness = match credentials.last() { Some(c) => match c.to_owned().witness {