Repository: ergoplatform/sigma-rust (language: rust)

Issue:
Switch CI to Rust 1.58 and fix clippy warnings



Discussion / hints:

Fix patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2a4dd81b2..c7edeb672 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -11,7 +11,7 @@ on:
       - synchronize
 
 env:
-  RUSTV: 1.57
+  RUSTV: '1.60'
 
 jobs:
   build_wo_default_features:
diff --git a/bindings/ergo-lib-c/src/box_builder.rs b/bindings/ergo-lib-c/src/box_builder.rs
index 87831fb4d..fa10147fa 100644
--- a/bindings/ergo-lib-c/src/box_builder.rs
+++ b/bindings/ergo-lib-c/src/box_builder.rs
@@ -185,6 +185,8 @@ pub unsafe extern "C" fn ergo_lib_ergo_box_candidate_builder_build(
 
 /// Drop `ErgoBoxCandidateBuilder`
 #[no_mangle]
-pub extern "C" fn ergo_lib_ergo_box_candidate_builder_delete(ptr: ErgoBoxCandidateBuilderPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_ergo_box_candidate_builder_delete(
+    ptr: ErgoBoxCandidateBuilderPtr,
+) {
+    delete_ptr(ptr)
 }
diff --git a/bindings/ergo-lib-c/src/box_selector.rs b/bindings/ergo-lib-c/src/box_selector.rs
index 886a6186f..50bb61520 100644
--- a/bindings/ergo-lib-c/src/box_selector.rs
+++ b/bindings/ergo-lib-c/src/box_selector.rs
@@ -45,8 +45,8 @@ pub unsafe extern "C" fn ergo_lib_box_selection_change(
 
 /// Drop `BoxSelection`
 #[no_mangle]
-pub extern "C" fn ergo_lib_box_selection_delete(ptr: BoxSelectionPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_box_selection_delete(ptr: BoxSelectionPtr) {
+    delete_ptr(ptr)
 }
 
 make_ffi_eq!(BoxSelection);
@@ -87,6 +87,6 @@ pub unsafe extern "C" fn ergo_lib_simple_box_selector_select(
 
 /// Drop `SimpleBoxSelector`
 #[no_mangle]
-pub extern "C" fn ergo_lib_simple_box_selector_delete(ptr: SimpleBoxSelectorPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_simple_box_selector_delete(ptr: SimpleBoxSelectorPtr) {
+    delete_ptr(ptr)
 }
diff --git a/bindings/ergo-lib-c/src/byte_array.rs b/bindings/ergo-lib-c/src/byte_array.rs
index f437479ff..dbbb8f731 100644
--- a/bindings/ergo-lib-c/src/byte_array.rs
+++ b/bindings/ergo-lib-c/src/byte_array.rs
@@ -19,8 +19,8 @@ pub unsafe extern "C" fn ergo_lib_byte_array_from_raw_parts(
 }
 
 #[no_mangle]
-pub extern "C" fn ergo_lib_byte_array_delete(ptr: ByteArrayPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_byte_array_delete(ptr: ByteArrayPtr) {
+    delete_ptr(ptr)
 }
 
 make_collection!(ByteArrays, ByteArray);
diff --git a/bindings/ergo-lib-c/src/context_extension.rs b/bindings/ergo-lib-c/src/context_extension.rs
index 31104757d..a43d6ec34 100644
--- a/bindings/ergo-lib-c/src/context_extension.rs
+++ b/bindings/ergo-lib-c/src/context_extension.rs
@@ -32,6 +32,6 @@ pub unsafe extern "C" fn ergo_lib_context_extension_keys(
 
 /// Drop `ContextExtension`
 #[no_mangle]
-pub extern "C" fn ergo_lib_context_extension_delete(ptr: ContextExtensionPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_context_extension_delete(ptr: ContextExtensionPtr) {
+    delete_ptr(ptr)
 }
diff --git a/bindings/ergo-lib-c/src/contract.rs b/bindings/ergo-lib-c/src/contract.rs
index 59994c7a0..d2c365a97 100644
--- a/bindings/ergo-lib-c/src/contract.rs
+++ b/bindings/ergo-lib-c/src/contract.rs
@@ -54,8 +54,8 @@ pub unsafe extern "C" fn ergo_lib_contract_ergo_tree(
 
 /// Drop `Contract`
 #[no_mangle]
-pub extern "C" fn ergo_lib_contract_delete(ptr: ContractPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_contract_delete(ptr: ContractPtr) {
+    delete_ptr(ptr)
 }
 
 make_ffi_eq!(Contract);
diff --git a/bindings/ergo-lib-c/src/data_input.rs b/bindings/ergo-lib-c/src/data_input.rs
index a6bedf291..ac6b8d68c 100644
--- a/bindings/ergo-lib-c/src/data_input.rs
+++ b/bindings/ergo-lib-c/src/data_input.rs
@@ -30,8 +30,8 @@ pub unsafe extern "C" fn ergo_lib_data_input_box_id(
 
 /// Drop `DataInput`
 #[no_mangle]
-pub extern "C" fn ergo_lib_data_input_delete(ptr: DataInputPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_data_input_delete(ptr: DataInputPtr) {
+    delete_ptr(ptr)
 }
 
 make_collection!(DataInputs, DataInput);
diff --git a/bindings/ergo-lib-c/src/ergo_box.rs b/bindings/ergo-lib-c/src/ergo_box.rs
index 750dad47d..dc6092af7 100644
--- a/bindings/ergo-lib-c/src/ergo_box.rs
+++ b/bindings/ergo-lib-c/src/ergo_box.rs
@@ -70,8 +70,8 @@ pub unsafe extern "C" fn ergo_lib_box_id_to_bytes(box_id_ptr: ConstBoxIdPtr, out
 
 /// Drop `BoxId`
 #[no_mangle]
-pub extern "C" fn ergo_lib_box_id_delete(ptr: BoxIdPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_box_id_delete(ptr: BoxIdPtr) {
+    delete_ptr(ptr)
 }
 
 make_ffi_eq!(BoxId);
@@ -122,8 +122,8 @@ pub unsafe extern "C" fn ergo_lib_box_value_sum_of(
 
 /// Drop `BoxValue`
 #[no_mangle]
-pub extern "C" fn ergo_lib_box_value_delete(ptr: BoxValuePtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_box_value_delete(ptr: BoxValuePtr) {
+    delete_ptr(ptr)
 }
 
 make_ffi_eq!(BoxValue);
@@ -190,8 +190,8 @@ pub unsafe extern "C" fn ergo_lib_ergo_box_candidate_box_value(
 
 /// Drop `ErgoBoxCandidate`
 #[no_mangle]
-pub extern "C" fn ergo_lib_ergo_box_candidate_delete(ptr: ErgoBoxCandidatePtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_ergo_box_candidate_delete(ptr: ErgoBoxCandidatePtr) {
+    delete_ptr(ptr)
 }
 
 make_collection!(ErgoBoxCandidates, ErgoBoxCandidate);
@@ -342,8 +342,8 @@ pub unsafe extern "C" fn ergo_lib_ergo_box_to_json_eip12(
 
 /// Drop `ErgoBox`
 #[no_mangle]
-pub extern "C" fn ergo_lib_ergo_box_delete(ptr: ErgoBoxPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_ergo_box_delete(ptr: ErgoBoxPtr) {
+    delete_ptr(ptr)
 }
 
 make_collection!(ErgoBoxes, ErgoBox);
@@ -384,8 +384,8 @@ pub unsafe extern "C" fn ergo_lib_ergo_box_assets_data_tokens(
 
 /// Drop `ErgoBoxAssetsData`
 #[no_mangle]
-pub extern "C" fn ergo_lib_ergo_box_assets_data_delete(ptr: ErgoBoxAssetsDataPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_ergo_box_assets_data_delete(ptr: ErgoBoxAssetsDataPtr) {
+    delete_ptr(ptr)
 }
 
 make_collection!(ErgoBoxAssetsDataList, ErgoBoxAssetsData);
diff --git a/bindings/ergo-lib-c/src/ergo_tree.rs b/bindings/ergo-lib-c/src/ergo_tree.rs
index 4bdfb2a05..b0302db6d 100644
--- a/bindings/ergo-lib-c/src/ergo_tree.rs
+++ b/bindings/ergo-lib-c/src/ergo_tree.rs
@@ -167,8 +167,8 @@ pub unsafe extern "C" fn ergo_lib_ergo_tree_template_bytes(
 
 /// Drop `ErgoTree`
 #[no_mangle]
-pub extern "C" fn ergo_lib_ergo_tree_delete(ptr: ErgoTreePtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_ergo_tree_delete(ptr: ErgoTreePtr) {
+    delete_ptr(ptr)
 }
 
 make_ffi_eq!(ErgoTree);
diff --git a/bindings/ergo-lib-c/src/input.rs b/bindings/ergo-lib-c/src/input.rs
index 646eea079..05992c940 100644
--- a/bindings/ergo-lib-c/src/input.rs
+++ b/bindings/ergo-lib-c/src/input.rs
@@ -32,8 +32,8 @@ pub unsafe extern "C" fn ergo_lib_unsigned_input_context_extension(
 
 /// Drop `UnsignedInput`
 #[no_mangle]
-pub extern "C" fn ergo_lib_unsigned_input_delete(ptr: UnsignedInputPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_unsigned_input_delete(ptr: UnsignedInputPtr) {
+    delete_ptr(ptr)
 }
 
 make_collection!(UnsignedInputs, UnsignedInput);
@@ -62,8 +62,8 @@ pub unsafe extern "C" fn ergo_lib_input_spending_proof(
 
 /// Drop `Input`
 #[no_mangle]
-pub extern "C" fn ergo_lib_input_delete(ptr: InputPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_input_delete(ptr: InputPtr) {
+    delete_ptr(ptr)
 }
 
 make_collection!(Inputs, Input);
@@ -120,6 +120,6 @@ pub unsafe extern "C" fn ergo_lib_prover_result_to_json(
 
 /// Drop `ProverResult`
 #[no_mangle]
-pub extern "C" fn ergo_lib_prover_result_delete(ptr: ProverResultPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_prover_result_delete(ptr: ProverResultPtr) {
+    delete_ptr(ptr)
 }
diff --git a/bindings/ergo-lib-c/src/lib.rs b/bindings/ergo-lib-c/src/lib.rs
index 9b2606da3..559d4dd4d 100644
--- a/bindings/ergo-lib-c/src/lib.rs
+++ b/bindings/ergo-lib-c/src/lib.rs
@@ -81,9 +81,9 @@ pub unsafe extern "C" fn ergo_lib_delete_string(ptr: *mut c_char) {
 }
 
 #[no_mangle]
-pub extern "C" fn ergo_lib_delete_error(error: ErrorPtr) {
+pub unsafe extern "C" fn ergo_lib_delete_error(error: ErrorPtr) {
     if !error.is_null() {
-        let boxed = unsafe { Box::from_raw(error) };
+        let boxed = Box::from_raw(error);
         std::mem::drop(boxed);
     }
 }
diff --git a/bindings/ergo-lib-c/src/reduced.rs b/bindings/ergo-lib-c/src/reduced.rs
index 3aecf7e73..cf03c484b 100644
--- a/bindings/ergo-lib-c/src/reduced.rs
+++ b/bindings/ergo-lib-c/src/reduced.rs
@@ -43,8 +43,8 @@ pub unsafe extern "C" fn ergo_lib_reduced_tx_unsigned_tx(
 
 /// Drop `ReducedTransaction`
 #[no_mangle]
-pub extern "C" fn ergo_lib_reduced_tx_delete(ptr: ReducedTransactionPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_reduced_tx_delete(ptr: ReducedTransactionPtr) {
+    delete_ptr(ptr)
 }
 
 /// Create empty proposition holder
@@ -67,6 +67,6 @@ pub unsafe extern "C" fn ergo_lib_propositions_add_proposition_from_bytes(
 
 /// Drop `Propositions`
 #[no_mangle]
-pub extern "C" fn ergo_lib_propositions_delete(ptr: PropositionsPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_propositions_delete(ptr: PropositionsPtr) {
+    delete_ptr(ptr)
 }
diff --git a/bindings/ergo-lib-c/src/secret_key.rs b/bindings/ergo-lib-c/src/secret_key.rs
index 04d4aea87..882fc930d 100644
--- a/bindings/ergo-lib-c/src/secret_key.rs
+++ b/bindings/ergo-lib-c/src/secret_key.rs
@@ -43,8 +43,8 @@ pub unsafe extern "C" fn ergo_lib_secret_key_to_bytes(
 
 /// Drop `SecretKey`
 #[no_mangle]
-pub extern "C" fn ergo_lib_secret_key_delete(ptr: SecretKeyPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_secret_key_delete(ptr: SecretKeyPtr) {
+    delete_ptr(ptr)
 }
 
 make_collection!(SecretKeys, SecretKey);
diff --git a/bindings/ergo-lib-c/src/token.rs b/bindings/ergo-lib-c/src/token.rs
index 2c0342c95..ceb4bcd77 100644
--- a/bindings/ergo-lib-c/src/token.rs
+++ b/bindings/ergo-lib-c/src/token.rs
@@ -46,8 +46,8 @@ pub unsafe extern "C" fn ergo_lib_token_id_to_str(
 
 /// Drop `TokenId`
 #[no_mangle]
-pub extern "C" fn ergo_lib_token_id_delete(ptr: TokenIdPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_token_id_delete(ptr: TokenIdPtr) {
+    delete_ptr(ptr)
 }
 
 make_ffi_eq!(TokenId);
@@ -75,8 +75,8 @@ pub unsafe extern "C" fn ergo_lib_token_amount_as_i64(
 
 /// Drop `TokenAmount`
 #[no_mangle]
-pub extern "C" fn ergo_lib_token_amount_delete(ptr: TokenAmountPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_token_amount_delete(ptr: TokenAmountPtr) {
+    delete_ptr(ptr)
 }
 
 make_ffi_eq!(TokenAmount);
@@ -133,8 +133,8 @@ pub unsafe extern "C" fn ergo_lib_token_to_json_eip12(
 
 /// Drop `Token`
 #[no_mangle]
-pub extern "C" fn ergo_lib_token_delete(ptr: TokenPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_token_delete(ptr: TokenPtr) {
+    delete_ptr(ptr)
 }
 
 make_ffi_eq!(Token);
@@ -186,6 +186,6 @@ pub unsafe extern "C" fn ergo_lib_tokens_add(
 
 /// Drop `Tokens`
 #[no_mangle]
-pub extern "C" fn ergo_lib_tokens_delete(ptr: TokensPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_tokens_delete(ptr: TokensPtr) {
+    delete_ptr(ptr)
 }
diff --git a/bindings/ergo-lib-c/src/transaction.rs b/bindings/ergo-lib-c/src/transaction.rs
index 4787f29a8..a850fb3fb 100644
--- a/bindings/ergo-lib-c/src/transaction.rs
+++ b/bindings/ergo-lib-c/src/transaction.rs
@@ -33,8 +33,8 @@ type ErgoBoxesPtr = CollectionPtr<ErgoBox>;
 
 /// Drop `CommitmentHint`
 #[no_mangle]
-pub extern "C" fn ergo_lib_commitment_hint_delete(ptr: CommitmentHintPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_commitment_hint_delete(ptr: CommitmentHintPtr) {
+    delete_ptr(ptr)
 }
 
 // `HintsBag` bindings -----------------------------------------------------------------------------
@@ -84,8 +84,8 @@ pub unsafe extern "C" fn ergo_lib_hints_bag_get(
 
 /// Drop `HintsBag`
 #[no_mangle]
-pub extern "C" fn ergo_lib_hints_bag_delete(ptr: HintsBagPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_hints_bag_delete(ptr: HintsBagPtr) {
+    delete_ptr(ptr)
 }
 
 // `TransactionHintsBag` bindings ------------------------------------------------------------------
@@ -148,8 +148,8 @@ pub unsafe extern "C" fn ergo_lib_transaction_extract_hints(
 
 /// Drop `TransactionHintsBag`
 #[no_mangle]
-pub extern "C" fn ergo_lib_transaction_hints_bag_delete(ptr: TransactionHintsBagPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_transaction_hints_bag_delete(ptr: TransactionHintsBagPtr) {
+    delete_ptr(ptr)
 }
 
 // `UnsignedTransaction` bindings ------------------------------------------------------------------
@@ -242,8 +242,8 @@ pub unsafe extern "C" fn ergo_lib_unsigned_tx_to_json_eip12(
 
 /// Drop `UnsignedTransaction`
 #[no_mangle]
-pub extern "C" fn ergo_lib_unsigned_tx_delete(ptr: UnsignedTransactionPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_unsigned_tx_delete(ptr: UnsignedTransactionPtr) {
+    delete_ptr(ptr)
 }
 
 // `Transaction` bindings --------------------------------------------------------------------------
@@ -351,8 +351,8 @@ pub unsafe extern "C" fn ergo_lib_tx_to_json_eip12(
 
 /// Drop `Transaction`
 #[no_mangle]
-pub extern "C" fn ergo_lib_tx_delete(ptr: TransactionPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_tx_delete(ptr: TransactionPtr) {
+    delete_ptr(ptr)
 }
 // `TxId` bindings ----------------------------------------------------------------------
 
@@ -386,8 +386,8 @@ pub unsafe extern "C" fn ergo_lib_tx_id_to_str(
 
 /// Drop `TxId`
 #[no_mangle]
-pub extern "C" fn ergo_lib_tx_id_delete(ptr: TxIdPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_tx_id_delete(ptr: TxIdPtr) {
+    delete_ptr(ptr)
 }
 
 make_ffi_eq!(TxId);
diff --git a/bindings/ergo-lib-c/src/tx_builder.rs b/bindings/ergo-lib-c/src/tx_builder.rs
index 8f28b9229..efb14a751 100644
--- a/bindings/ergo-lib-c/src/tx_builder.rs
+++ b/bindings/ergo-lib-c/src/tx_builder.rs
@@ -154,6 +154,6 @@ pub unsafe extern "C" fn ergo_lib_tx_builder_min_change_value(
 
 /// Drop `TxBuilder`
 #[no_mangle]
-pub extern "C" fn ergo_lib_tx_builder_delete(ptr: TxBuilderPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_tx_builder_delete(ptr: TxBuilderPtr) {
+    delete_ptr(ptr)
 }
diff --git a/bindings/ergo-lib-c/src/wallet.rs b/bindings/ergo-lib-c/src/wallet.rs
index 501dd4f91..29b8a7e3b 100644
--- a/bindings/ergo-lib-c/src/wallet.rs
+++ b/bindings/ergo-lib-c/src/wallet.rs
@@ -161,6 +161,6 @@ pub unsafe extern "C" fn ergo_lib_wallet_generate_commitments_for_reduced_transa
 
 /// Drop `Wallet`
 #[no_mangle]
-pub extern "C" fn ergo_lib_wallet_delete(ptr: WalletPtr) {
-    unsafe { delete_ptr(ptr) }
+pub unsafe extern "C" fn ergo_lib_wallet_delete(ptr: WalletPtr) {
+    delete_ptr(ptr)
 }
diff --git a/bindings/ergo-lib-wasm/src/token.rs b/bindings/ergo-lib-wasm/src/token.rs
index 5105f608f..352459cb9 100644
--- a/bindings/ergo-lib-wasm/src/token.rs
+++ b/bindings/ergo-lib-wasm/src/token.rs
@@ -171,7 +171,7 @@ impl Tokens {
 impl From<Tokens> for Option<chain::ergo_box::BoxTokens> {
     fn from(v: Tokens) -> Self {
         chain::ergo_box::BoxTokens::from_vec(
-            v.0.iter().cloned().flatten().map(Into::into).collect(),
+            v.0.iter().flatten().cloned().map(Into::into).collect(),
         )
         .ok()
     }
diff --git a/bindings/ergo-lib-wasm/src/transaction.rs b/bindings/ergo-lib-wasm/src/transaction.rs
index e521482db..7ea7abbcb 100644
--- a/bindings/ergo-lib-wasm/src/transaction.rs
+++ b/bindings/ergo-lib-wasm/src/transaction.rs
@@ -42,9 +42,7 @@ pub struct HintsBag(
 impl HintsBag {
     /// Empty HintsBag
     pub fn empty() -> HintsBag {
-        HintsBag {
-            0: ergo_lib::ergotree_interpreter::sigma_protocol::prover::hint::HintsBag::empty(),
-        }
+        HintsBag(ergo_lib::ergotree_interpreter::sigma_protocol::prover::hint::HintsBag::empty())
     }
 
     /// Add commitment hint to the bag
@@ -82,9 +80,7 @@ pub struct TransactionHintsBag(pub(crate) ergo_lib::wallet::multi_sig::Transacti
 impl TransactionHintsBag {
     /// Empty TransactionHintsBag
     pub fn empty() -> TransactionHintsBag {
-        TransactionHintsBag {
-            0: ergo_lib::wallet::multi_sig::TransactionHintsBag::empty(),
-        }
+        TransactionHintsBag(ergo_lib::wallet::multi_sig::TransactionHintsBag::empty())
     }
 
     /// Adding hints for input
diff --git a/ergo-lib/src/wallet/box_selector.rs b/ergo-lib/src/wallet/box_selector.rs
index 5146c2311..fb3d24b0e 100644
--- a/ergo-lib/src/wallet/box_selector.rs
+++ b/ergo-lib/src/wallet/box_selector.rs
@@ -195,7 +195,7 @@ mod tests {
             (any_with::<BoxValue>(args), of(vec(any::<Token>(), 0..3)))
                 .prop_map(|(value, tokens)| Self {
                     value,
-                    tokens: tokens.map(BoxTokens::from_vec).map(Result::ok).flatten(),
+                    tokens: tokens.map(BoxTokens::from_vec).and_then(Result::ok),
                 })
                 .boxed()
         }
diff --git a/ergo-lib/src/wallet/box_selector/simple.rs b/ergo-lib/src/wallet/box_selector/simple.rs
index 7347a2b71..c15a02c1c 100644
--- a/ergo-lib/src/wallet/box_selector/simple.rs
+++ b/ergo-lib/src/wallet/box_selector/simple.rs
@@ -246,7 +246,7 @@ mod tests {
                         target_balance in
                         any_with::<BoxValue>((BoxValue::MIN_RAW * 100 .. BoxValue::MIN_RAW * 1500).into())) {
             let first_input_box = inputs.get(0).unwrap().clone();
-            prop_assume!(!first_input_box.tokens.is_none());
+            prop_assume!(first_input_box.tokens.is_some());
             let first_input_box_token = first_input_box.tokens.as_ref().unwrap().first();
             let first_input_box_token_amount = u64::from(first_input_box_token.amount);
             prop_assume!(first_input_box_token_amount > 1);
diff --git a/ergo-lib/src/wallet/derivation_path.rs b/ergo-lib/src/wallet/derivation_path.rs
index 62e25cd02..8b46a1fa3 100644
--- a/ergo-lib/src/wallet/derivation_path.rs
+++ b/ergo-lib/src/wallet/derivation_path.rs
@@ -58,8 +58,8 @@ pub enum ChildIndex {
 impl fmt::Display for ChildIndex {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match self {
-            ChildIndex::Hardened(i) => write!(f, "{}'", i.0.to_string()),
-            ChildIndex::Normal(i) => write!(f, "{}", i.0.to_string()),
+            ChildIndex::Hardened(i) => write!(f, "{}'", i.0),
+            ChildIndex::Normal(i) => write!(f, "{}", i.0),
         }
     }
 }
@@ -69,7 +69,7 @@ impl FromStr for ChildIndex {
 
     fn from_str(s: &str) -> Result<Self, Self::Err> {
         if s.contains('\'') {
-            let idx = s.replace("'", "");
+            let idx = s.replace('\'', "");
             Ok(ChildIndex::Hardened(ChildIndexHardened::from_31_bit(
                 idx.parse()?,
             )?))
@@ -265,8 +265,7 @@ impl FromStr for DerivationPath {
         }
         let path = parts
             .into_iter()
-            .map(ChildIndex::from_str)
-            .flatten()
+            .flat_map(ChildIndex::from_str)
             .collect::<Vec<_>>();
         Ok(path.into_boxed_slice().into())
     }
diff --git a/ergo-lib/src/wallet/ext_pub_key.rs b/ergo-lib/src/wallet/ext_pub_key.rs
index 51349ee7c..5c379033a 100644
--- a/ergo-lib/src/wallet/ext_pub_key.rs
+++ b/ergo-lib/src/wallet/ext_pub_key.rs
@@ -125,8 +125,7 @@ impl ExtPubKey {
         } else {
             Err(ExtPubKeyError::IncompatibleDerivation(format!(
                 "{}, {}",
-                up_path.to_string(),
-                self.derivation_path.to_string()
+                up_path, self.derivation_path
             )))
         }
     }
diff --git a/ergo-lib/src/wallet/ext_secret_key.rs b/ergo-lib/src/wallet/ext_secret_key.rs
index f5a958c7e..4ef5bcdbe 100644
--- a/ergo-lib/src/wallet/ext_secret_key.rs
+++ b/ergo-lib/src/wallet/ext_secret_key.rs
@@ -164,8 +164,7 @@ impl ExtSecretKey {
         } else {
             Err(ExtSecretKeyError::IncompatibleDerivation(format!(
                 "{}, {}",
-                up_path.to_string(),
-                self.derivation_path.to_string()
+                up_path, self.derivation_path
             )))
         }
     }
diff --git a/ergo-lib/src/wallet/multi_sig.rs b/ergo-lib/src/wallet/multi_sig.rs
index eb220325b..37d368937 100644
--- a/ergo-lib/src/wallet/multi_sig.rs
+++ b/ergo-lib/src/wallet/multi_sig.rs
@@ -323,6 +323,9 @@ pub fn extract_hints(
             extension,
         });
         let tree = input_box.ergo_tree.clone();
+
+        // `i` is guaranteed to be a valid index since it's coming from an `enumerate()` call above.
+        #[allow(clippy::unwrap_used)]
         let proof: ProofBytes = tx_ctx
             .spending_tx
             .inputs
diff --git a/ergo-lib/src/wallet/signing.rs b/ergo-lib/src/wallet/signing.rs
index 3e2bc7cb8..d935500d1 100644
--- a/ergo-lib/src/wallet/signing.rs
+++ b/ergo-lib/src/wallet/signing.rs
@@ -240,6 +240,9 @@ pub fn sign_reduced_transaction(
     let message_to_sign = tx.bytes_to_sign()?;
     let signed_inputs = tx.inputs.enumerated().try_mapped(|(idx, input)| {
         let inputs = reduced_tx.reduced_inputs();
+
+        // `idx` is valid since it's indexing over `tx.inputs`
+        #[allow(clippy::unwrap_used)]
         let reduced_input = inputs.get(idx).unwrap();
         let mut hints_bag = HintsBag::empty();
         if let Some(bag) = tx_hints {
diff --git a/ergo-p2p/src/peer_info.rs b/ergo-p2p/src/peer_info.rs
index abd7f1082..41b704122 100644
--- a/ergo-p2p/src/peer_info.rs
+++ b/ergo-p2p/src/peer_info.rs
@@ -40,7 +40,7 @@ impl PeerInfo {
         let peer_spec = PeerSpec::new(
             "unknown",
             ProtocolVersion::INITIAL,
-            &format!("unknown-{}", addr.to_string()),
+            &format!("unknown-{}", addr),
             Some(addr),
             None,
         );
diff --git a/ergotree-interpreter/src/sigma_protocol/fiat_shamir.rs b/ergotree-interpreter/src/sigma_protocol/fiat_shamir.rs
index 390945ef6..6901a9ff3 100644
--- a/ergotree-interpreter/src/sigma_protocol/fiat_shamir.rs
+++ b/ergotree-interpreter/src/sigma_protocol/fiat_shamir.rs
@@ -45,7 +45,7 @@ pub fn fiat_shamir_hash_fn(input: &[u8]) -> FiatShamirHash {
     let mut hasher = VarBlake2b::new(GROUP_SIZE).unwrap();
     hasher.update(input);
     let hash = hasher.finalize_boxed();
-    let taken: Vec<u8> = hash.to_vec().into_iter().take(SOUNDNESS_BYTES).collect();
+    let taken: Vec<u8> = hash.iter().copied().take(SOUNDNESS_BYTES).collect();
     // unwrap is safe due to hash size is expected to be SOUNDNESS_BYTES
     #[allow(clippy::unwrap_used)]
     FiatShamirHash(taken.into_boxed_slice().try_into().unwrap())
diff --git a/ergotree-interpreter/src/sigma_protocol/private_input.rs b/ergotree-interpreter/src/sigma_protocol/private_input.rs
index e79195f5c..72cef260f 100644
--- a/ergotree-interpreter/src/sigma_protocol/private_input.rs
+++ b/ergotree-interpreter/src/sigma_protocol/private_input.rs
@@ -47,8 +47,7 @@ impl DlogProverInput {
     pub fn from_base16_str(str: String) -> Option<DlogProverInput> {
         base16::decode(&str)
             .ok()
-            .map(|bytes| bytes.as_slice().try_into().ok().map(Self::from_bytes))
-            .flatten()
+            .and_then(|bytes| bytes.as_slice().try_into().ok().map(Self::from_bytes))
             .flatten()
     }
 
diff --git a/ergotree-ir/src/chain/address.rs b/ergotree-ir/src/chain/address.rs
index 4f3f02f16..f5f4fff71 100644
--- a/ergotree-ir/src/chain/address.rs
+++ b/ergotree-ir/src/chain/address.rs
@@ -413,8 +413,8 @@ impl AddressEncoder {
 
     fn calc_checksum(bytes: &[u8]) -> [u8; AddressEncoder::CHECKSUM_LENGTH] {
         let v: Vec<u8> = blake2b256_hash(bytes)
-            .to_vec()
-            .into_iter()
+            .iter()
+            .copied()
             .take(AddressEncoder::CHECKSUM_LENGTH)
             .collect();
         #[allow(clippy::unwrap_used)]
diff --git a/ergotree-ir/src/chain/ergo_box.rs b/ergotree-ir/src/chain/ergo_box.rs
index d47e0e8ff..f69e895a0 100644
--- a/ergotree-ir/src/chain/ergo_box.rs
+++ b/ergotree-ir/src/chain/ergo_box.rs
@@ -273,7 +273,7 @@ impl From<ErgoBox> for super::json::ergo_box::ErgoBoxJson {
             .as_ref()
             .map(BoxTokens::as_vec)
             .cloned()
-            .unwrap_or_else(Vec::new); // JSON serialization for ErgoBox requires that tokens be [] instead of null
+            .unwrap_or_default(); // JSON serialization for ErgoBox requires that tokens be [] instead of null
         super::json::ergo_box::ErgoBoxJson {
             box_id: Some(ergo_box.box_id),
             value: ergo_box.value,
diff --git a/ergotree-ir/src/serialization/bin_op.rs b/ergotree-ir/src/serialization/bin_op.rs
index 685207210..e72a9fa54 100644
--- a/ergotree-ir/src/serialization/bin_op.rs
+++ b/ergotree-ir/src/serialization/bin_op.rs
@@ -46,6 +46,7 @@ pub fn bin_op_sigma_parse<R: SigmaByteRead>(
     let tag = r.get_u8()?;
     Ok(if tag == OpCode::COLL_OF_BOOL_CONST.value() {
         let bools = r.get_bits(2)?;
+        #[allow(clippy::unwrap_used)]
         BinOp {
             kind: op_kind,
             left: Box::new(Expr::Const((*bools.get(0).unwrap()).into())),
diff --git a/ergotree-ir/src/serialization/constant_store.rs b/ergotree-ir/src/serialization/constant_store.rs
index 9d1a5ef98..1032e3265 100644
--- a/ergotree-ir/src/serialization/constant_store.rs
+++ b/ergotree-ir/src/serialization/constant_store.rs
@@ -39,6 +39,7 @@ impl ConstantStore {
     }
 }
 
+#[allow(clippy::unwrap_used)]
 #[cfg(test)]
 #[cfg(feature = "arbitrary")]
 mod tests {
diff --git a/ergotree-ir/src/serialization/expr.rs b/ergotree-ir/src/serialization/expr.rs
index 044acd01c..f4b97ba50 100644
--- a/ergotree-ir/src/serialization/expr.rs
+++ b/ergotree-ir/src/serialization/expr.rs
@@ -98,6 +98,7 @@ impl Expr {
                     if r.substitute_placeholders() {
                         // ConstantPlaceholder itself can be created only if a corresponding
                         // constant is in the constant_store, thus unwrap() is safe here
+                        #[allow(clippy::unwrap_used)]
                         let c = r.constant_store().get(cp.id).unwrap();
                         Ok(Expr::Const(c.clone()))
                     } else {
diff --git a/ergotree-ir/src/sigma_protocol/dlog_group.rs b/ergotree-ir/src/sigma_protocol/dlog_group.rs
index eb9487be2..4a84e51f2 100644
--- a/ergotree-ir/src/sigma_protocol/dlog_group.rs
+++ b/ergotree-ir/src/sigma_protocol/dlog_group.rs
@@ -62,8 +62,7 @@ impl EcPoint {
     pub fn from_base16_str(str: String) -> Option<Self> {
         base16::decode(&str)
             .ok()
-            .map(|bytes| Self::sigma_parse_bytes(&bytes).ok())
-            .flatten()
+            .and_then(|bytes| Self::sigma_parse_bytes(&bytes).ok())
     }
 }
 
diff --git a/ergotree-ir/src/sigma_protocol/sigma_boolean.rs b/ergotree-ir/src/sigma_protocol/sigma_boolean.rs
index 7e32c953d..fe4ffc567 100644
--- a/ergotree-ir/src/sigma_protocol/sigma_boolean.rs
+++ b/ergotree-ir/src/sigma_protocol/sigma_boolean.rs
@@ -244,7 +244,7 @@ pub struct SigmaProp(SigmaBoolean);
 impl SigmaProp {
     /// create new sigma proposition from [`SigmaBoolean`] value
     pub fn new(sbool: SigmaBoolean) -> Self {
-        SigmaProp { 0: sbool }
+        SigmaProp(sbool)
     }
 
     /// get [`SigmaBoolean`] value


Test patch: