From 7ff00e576060f885f7a578a36e7fa48557848ac1 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Jan 2024 11:16:48 +0000 Subject: [PATCH] clippy automatic fixes --- src/claimant.rs | 8 ++++---- src/get_liquidity_pool.rs | 4 +--- src/liquidity_pool_asset.rs | 8 ++------ src/operation.rs | 4 +--- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/claimant.rs b/src/claimant.rs index 31aaa29..66407f9 100644 --- a/src/claimant.rs +++ b/src/claimant.rs @@ -41,7 +41,7 @@ impl ClaimantBehavior for Claimant { let key = PublicKey::from_string(destination.unwrap()); if key.is_err() { - return Err("accountId is invalid".into()); + return Err("accountId is invalid"); } let actual_predicate = match predicate { @@ -105,7 +105,7 @@ impl ClaimantBehavior for Claimant { fn to_xdr_object(&self) -> stellar_xdr::next::Claimant { let claimant = stellar_xdr::next::ClaimantV0 { - destination: Keypair::from_public_key(&self.destination.clone().unwrap().as_str()) + destination: Keypair::from_public_key(self.destination.clone().unwrap().as_str()) .unwrap() .xdr_account_id(), predicate: self.predicate.clone(), @@ -115,8 +115,8 @@ impl ClaimantBehavior for Claimant { } fn destination(&self) -> Option { - let val = self.destination.clone(); - val + + self.destination.clone() } fn set_destination(&mut self, _value: String) { diff --git a/src/get_liquidity_pool.rs b/src/get_liquidity_pool.rs index a18c5de..4309056 100644 --- a/src/get_liquidity_pool.rs +++ b/src/get_liquidity_pool.rs @@ -34,9 +34,7 @@ impl LiquidityPoolBehavior for LiquidityPool { "liquidityPoolType is invalid", ))); } - let liquidity_pool_parametes_x = match liquidity_pool_parameters.clone() { - LiquidityPoolParameters::LiquidityPoolConstantProduct(x) => x, - }; + let LiquidityPoolParameters::LiquidityPoolConstantProduct(liquidity_pool_parametes_x) = liquidity_pool_parameters.clone(); if liquidity_pool_parametes_x.fee != LIQUIDITY_POOL_FEE_V18 { return Err(Box::new(std::io::Error::new( diff --git a/src/liquidity_pool_asset.rs b/src/liquidity_pool_asset.rs index 5d6c0f8..5dac1e0 100644 --- a/src/liquidity_pool_asset.rs +++ b/src/liquidity_pool_asset.rs @@ -48,11 +48,7 @@ impl LiquidityPoolAssetBehavior for LiquidityPoolAsset { fn from_operation(ct_asset_xdr: &ChangeTrustAsset) -> Result { match ct_asset_xdr { ChangeTrustAsset::PoolShare(x) => { - let val = match x { - stellar_xdr::next::LiquidityPoolParameters::LiquidityPoolConstantProduct(x) => { - x - } - }; + let stellar_xdr::next::LiquidityPoolParameters::LiquidityPoolConstantProduct(val) = x; let asset_a = Asset::from_operation(val.asset_a.clone()).unwrap(); let asset_b = Asset::from_operation(val.asset_b.clone()).unwrap(); @@ -60,7 +56,7 @@ impl LiquidityPoolAssetBehavior for LiquidityPoolAsset { Ok(LiquidityPoolAsset::new(asset_a, asset_b, fee)?) } - _ => Err(format!("Invalid asset type")), + _ => Err("Invalid asset type".to_string()), } } diff --git a/src/operation.rs b/src/operation.rs index 07f92aa..b1b2dfe 100644 --- a/src/operation.rs +++ b/src/operation.rs @@ -623,9 +623,7 @@ fn from_xdr_price(price: stellar_xdr::next::Price) -> String { } fn account_id_to_address(account_id: &AccountId) -> String { - let val = match account_id.0.clone() { - stellar_xdr::next::PublicKey::PublicKeyTypeEd25519(x) => x, - }; + let stellar_xdr::next::PublicKey::PublicKeyTypeEd25519(val) = account_id.0.clone(); let key: Result = PublicKey::from_string(val.to_string().as_str());