Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
build: bump MSRV to 1.85.0 (#9390)
Shailesh1d8290cec187
diff --git a/.deepsource.toml b/.deepsource.tomlindex 8d0b3c501a..5db492d68c 100644--- a/.deepsource.toml+++ b/.deepsource.toml@@ -13,4 +13,4 @@ name = "rust"enabled = true[analyzers.meta]-msrv = "1.80.0"+msrv = "1.85.0"diff --git a/Cargo.toml b/Cargo.tomlindex acd8edf0b1..9ab0490f01 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -2,7 +2,7 @@resolver = "2"members = ["crates/*"]package.edition = "2021"-package.rust-version = "1.80.0"+package.rust-version = "1.85.0"package.license = "Apache-2.0"[workspace.dependencies]diff --git a/INSTALL_dependencies.sh b/INSTALL_dependencies.shindex bc7d502b35..8e21bf119b 100755--- a/INSTALL_dependencies.sh+++ b/INSTALL_dependencies.sh@@ -9,7 +9,7 @@ if [[ "${TRACE-0}" == "1" ]]; thenset -o xtracefi-RUST_MSRV="1.80.0"+RUST_MSRV="1.85.0"_DB_NAME="hyperswitch_db"_DB_USER="db_user"_DB_PASS="db_password"diff --git a/crates/analytics/src/search.rs b/crates/analytics/src/search.rsindex f3bda521c5..7fda015144 100644--- a/crates/analytics/src/search.rs+++ b/crates/analytics/src/search.rs@@ -26,7 +26,7 @@ pub async fn msearch_results(&& req.filters.as_ref()- .map_or(true, |filters| filters.is_all_none())+ .is_none_or(|filters| filters.is_all_none()){return Err(OpenSearchError::BadRequestError("Both query and filters are empty".to_string(),@@ -232,7 +232,7 @@ pub async fn search_results(&& search_req.filters.as_ref()- .map_or(true, |filters| filters.is_all_none())+ .is_none_or(|filters| filters.is_all_none()){return Err(OpenSearchError::BadRequestError("Both query and filters are empty".to_string(),diff --git a/crates/euclid/src/backend/vir_interpreter.rs b/crates/euclid/src/backend/vir_interpreter.rsindex 7181e501fa..67f59594bb 100644--- a/crates/euclid/src/backend/vir_interpreter.rs+++ b/crates/euclid/src/backend/vir_interpreter.rs@@ -42,7 +42,7 @@ wherefn eval_statement(stmt: &vir::ValuedIfStatement, ctx: &types::Context) -> bool {if Self::eval_condition(&stmt.condition, ctx) {{- stmt.nested.as_ref().map_or(true, |nested_stmts| {+ stmt.nested.as_ref().is_none_or(|nested_stmts| {nested_stmts.iter().any(|s| Self::eval_statement(s, ctx))})}diff --git a/crates/euclid/src/dssa/state_machine.rs b/crates/euclid/src/dssa/state_machine.rsindex 93d394eece..bce27ebc5f 100644--- a/crates/euclid/src/dssa/state_machine.rs+++ b/crates/euclid/src/dssa/state_machine.rs@@ -424,7 +424,7 @@ impl<'a> ProgramStateMachine<'a> {pub fn is_finished(&self) -> bool {self.current_rule_machine.as_ref()- .map_or(true, |rsm| rsm.is_finished())+ .is_none_or(|rsm| rsm.is_finished())&& self.rule_machines.is_empty()}@@ -449,7 +449,7 @@ impl<'a> ProgramStateMachine<'a> {if self.current_rule_machine.as_ref()- .map_or(true, |rsm| rsm.is_finished())+ .is_none_or(|rsm| rsm.is_finished()){self.current_rule_machine = self.rule_machines.pop();context.clear();diff --git a/crates/hyperswitch_domain_models/src/merchant_connector_account.rs b/crates/hyperswitch_domain_models/src/merchant_connector_account.rsindex a4f49f1e84..5ba7589378 100644--- a/crates/hyperswitch_domain_models/src/merchant_connector_account.rs+++ b/crates/hyperswitch_domain_models/src/merchant_connector_account.rs@@ -392,14 +392,16 @@ impl FlattenedPaymentMethodsEnabled {let request_payment_methods_enabled =payment_method.payment_method_subtypes.unwrap_or_default();let length = request_payment_methods_enabled.len();- request_payment_methods_enabled.into_iter().zip(- std::iter::repeat((- connector,- merchant_connector_id.clone(),- payment_method.payment_method_type,+ request_payment_methods_enabled+ .into_iter()+ .zip(std::iter::repeat_n(+ (+ connector,+ merchant_connector_id.clone(),+ payment_method.payment_method_type,+ ),+ length,))- .take(length),- )})},)diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex 980e1e8343..322557129d 100644--- a/crates/router/src/core/payment_methods/cards.rs+++ b/crates/router/src/core/payment_methods/cards.rs@@ -3988,9 +3988,8 @@ fn filter_installment_based(payment_method: &RequestPaymentMethodTypes,installment_payment_enabled: Option<bool>,) -> bool {- installment_payment_enabled.map_or(true, |enabled| {- payment_method.installment_payment_enabled == Some(enabled)- })+ installment_payment_enabled+ .is_none_or(|enabled| payment_method.installment_payment_enabled == Some(enabled))}fn filter_pm_card_network_based(@@ -4016,16 +4015,14 @@ fn filter_pm_based_on_allowed_types(allowed_types: Option<&Vec<api_enums::PaymentMethodType>>,payment_method_type: api_enums::PaymentMethodType,) -> bool {- allowed_types.map_or(true, |pm| pm.contains(&payment_method_type))+ allowed_types.is_none_or(|pm| pm.contains(&payment_method_type))}fn filter_recurring_based(payment_method: &RequestPaymentMethodTypes,recurring_enabled: Option<bool>,) -> bool {- recurring_enabled.map_or(true, |enabled| {- payment_method.recurring_enabled == Some(enabled)- })+ recurring_enabled.is_none_or(|enabled| payment_method.recurring_enabled == Some(enabled))}#[cfg(feature = "v1")]diff --git a/crates/router/src/core/payments/payment_methods.rs b/crates/router/src/core/payments/payment_methods.rsindex 61a8f71a1f..36a8120fd1 100644--- a/crates/router/src/core/payments/payment_methods.rs+++ b/crates/router/src/core/payments/payment_methods.rs@@ -547,9 +547,9 @@ fn filter_country_based(address: Option<&hyperswitch_domain_models::address::AddressDetails>,pm: &common_types::payment_methods::RequestPaymentMethodTypes,) -> bool {- address.map_or(true, |address| {- address.country.as_ref().map_or(true, |country| {- pm.accepted_countries.as_ref().map_or(true, |ac| match ac {+ address.is_none_or(|address| {+ address.country.as_ref().is_none_or(|country| {+ pm.accepted_countries.as_ref().is_none_or(|ac| match ac {common_types::payment_methods::AcceptedCountries::EnableOnly(acc) => {acc.contains(country)}@@ -568,7 +568,7 @@ fn filter_currency_based(currency: common_enums::Currency,pm: &common_types::payment_methods::RequestPaymentMethodTypes,) -> bool {- pm.accepted_currencies.as_ref().map_or(true, |ac| match ac {+ pm.accepted_currencies.as_ref().is_none_or(|ac| match ac {common_types::payment_methods::AcceptedCurrencies::EnableOnly(acc) => {acc.contains(¤cy)}@@ -641,9 +641,7 @@ fn filter_recurring_based(payment_method: &common_types::payment_methods::RequestPaymentMethodTypes,recurring_enabled: Option<bool>,) -> bool {- recurring_enabled.map_or(true, |enabled| {- payment_method.recurring_enabled == Some(enabled)- })+ recurring_enabled.is_none_or(|enabled| payment_method.recurring_enabled == Some(enabled))}// filter based on valid amount range of payment method type@@ -704,7 +702,7 @@ fn filter_allowed_payment_method_types_based(allowed_types: Option<&Vec<api_models::enums::PaymentMethodType>>,payment_method_type: api_models::enums::PaymentMethodType,) -> bool {- allowed_types.map_or(true, |pm| pm.contains(&payment_method_type))+ allowed_types.is_none_or(|pm| pm.contains(&payment_method_type))}// filter based on card networksdiff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rsindex e4ce038b3b..5e0f0eb1b8 100644--- a/crates/router/src/core/payments/routing.rs+++ b/crates/router/src/core/payments/routing.rs@@ -960,7 +960,7 @@ pub async fn perform_cgraph_filtering(.change_context(errors::RoutingError::KgraphAnalysisError)?;let filter_eligible =- eligible_connectors.map_or(true, |list| list.contains(&routable_connector));+ eligible_connectors.is_none_or(|list| list.contains(&routable_connector));if cgraph_eligible && filter_eligible {final_selection.push(choice);diff --git a/crates/router/src/core/user_role/role.rs b/crates/router/src/core/user_role/role.rsindex cbd49a1439..25388c1381 100644--- a/crates/router/src/core/user_role/role.rs+++ b/crates/router/src/core/user_role/role.rs@@ -507,9 +507,9 @@ pub async fn list_roles_with_info(.into_iter().filter_map(|role_info| {let is_lower_entity = user_role_entity >= role_info.get_entity_type();- let request_filter = request.entity_type.map_or(true, |entity_type| {- entity_type == role_info.get_entity_type()- });+ let request_filter = request+ .entity_type+ .is_none_or(|entity_type| entity_type == role_info.get_entity_type());(is_lower_entity && request_filter).then_some({let permission_groups = role_info.get_permission_groups();@@ -539,9 +539,9 @@ pub async fn list_roles_with_info(.into_iter().filter_map(|role_info| {let is_lower_entity = user_role_entity >= role_info.get_entity_type();- let request_filter = request.entity_type.map_or(true, |entity_type| {- entity_type == role_info.get_entity_type()- });+ let request_filter = request+ .entity_type+ .is_none_or(|entity_type| entity_type == role_info.get_entity_type());(is_lower_entity && request_filter).then_some(role_api::RoleInfoResponseNew {role_id: role_info.get_role_id().to_string(),diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rsindex b248955de4..44322d4384 100644--- a/crates/router/src/core/webhooks/incoming.rs+++ b/crates/router/src/core/webhooks/incoming.rs@@ -2373,7 +2373,7 @@ async fn update_connector_mandate_details(.clone().get_required_value("merchant_connector_id")?;- if mandate_details.payments.as_ref().map_or(true, |payments| {+ if mandate_details.payments.as_ref().is_none_or(|payments| {!payments.0.contains_key(&merchant_connector_account_id)}) {// Update the payment attempt to maintain consistency across tables.diff --git a/crates/router/src/db/dispute.rs b/crates/router/src/db/dispute.rsindex 6ba8a72f5c..02877131c9 100644--- a/crates/router/src/db/dispute.rs+++ b/crates/router/src/db/dispute.rs@@ -263,38 +263,38 @@ impl DisputeInterface for MockDb {&& dispute_constraints.dispute_id.as_ref()- .map_or(true, |id| &dispute.dispute_id == id)+ .is_none_or(|id| &dispute.dispute_id == id)&& dispute_constraints.payment_id.as_ref()- .map_or(true, |id| &dispute.payment_id == id)+ .is_none_or(|id| &dispute.payment_id == id)&& dispute_constraints.profile_id.as_ref()- .map_or(true, |profile_ids| {+ .is_none_or(|profile_ids| {dispute.profile_id.as_ref()- .map_or(true, |id| profile_ids.contains(id))+ .is_none_or(|id| profile_ids.contains(id))})&& dispute_constraints.dispute_status.as_ref()- .map_or(true, |statuses| statuses.contains(&dispute.dispute_status))+ .is_none_or(|statuses| statuses.contains(&dispute.dispute_status))&& dispute_constraints.dispute_stage.as_ref()- .map_or(true, |stages| stages.contains(&dispute.dispute_stage))- && dispute_constraints.reason.as_ref().map_or(true, |reason| {+ .is_none_or(|stages| stages.contains(&dispute.dispute_stage))+ && dispute_constraints.reason.as_ref().is_none_or(|reason| {dispute.connector_reason.as_ref()- .map_or(true, |d_reason| d_reason == reason)+ .is_none_or(|d_reason| d_reason == reason)})&& dispute_constraints.connector.as_ref()- .map_or(true, |connectors| {+ .is_none_or(|connectors| {connectors.iter().any(|connector| dispute.connector.as_str() == *connector)@@ -302,13 +302,11 @@ impl DisputeInterface for MockDb {&& dispute_constraints.merchant_connector_id.as_ref()- .map_or(true, |id| {- dispute.merchant_connector_id.as_ref() == Some(id)- })+ .is_none_or(|id| dispute.merchant_connector_id.as_ref() == Some(id))&& dispute_constraints.currency.as_ref()- .map_or(true, |currencies| {+ .is_none_or(|currencies| {currencies.iter().any(|currency| {dispute.dispute_currency@@ -316,16 +314,13 @@ impl DisputeInterface for MockDb {.unwrap_or(dispute.currency.as_str() == currency.to_string())})})- && dispute_constraints- .time_range- .as_ref()- .map_or(true, |range| {- let dispute_time = dispute.created_at;- dispute_time >= range.start_time- && range- .end_time- .map_or(true, |end_time| dispute_time <= end_time)- })+ && dispute_constraints.time_range.as_ref().is_none_or(|range| {+ let dispute_time = dispute.created_at;+ dispute_time >= range.start_time+ && range+ .end_time+ .is_none_or(|end_time| dispute_time <= end_time)+ })}).skip(offset_usize).take(limit_usize)@@ -428,15 +423,13 @@ impl DisputeInterface for MockDb {&& time_range.end_time.as_ref()- .map(|received_end_time| received_end_time >= &d.created_at)- .unwrap_or(true)+ .is_none_or(|received_end_time| received_end_time >= &d.created_at)&& profile_id_list.as_ref().zip(d.profile_id.as_ref())- .map(|(received_profile_list, received_profile_id)| {+ .is_none_or(|(received_profile_list, received_profile_id)| {received_profile_list.contains(received_profile_id)})- .unwrap_or(true)}).cloned().collect::<Vec<storage::Dispute>>();diff --git a/crates/router/src/db/refund.rs b/crates/router/src/db/refund.rsindex 1896a8f8a9..6f181ba201 100644--- a/crates/router/src/db/refund.rs+++ b/crates/router/src/db/refund.rs@@ -1405,13 +1405,13 @@ impl RefundInterface for MockDb {refund_details.payment_id.clone()- .map_or(true, |id| id == refund.payment_id)+ .is_none_or(|id| id == refund.payment_id)}).filter(|refund| {refund_details.refund_id.clone()- .map_or(true, |id| id == refund.refund_id)+ .is_none_or(|id| id == refund.refund_id)}).filter(|refund| {refund.profile_id.as_ref().is_some_and(|profile_id| {@@ -1432,15 +1432,11 @@ impl RefundInterface for MockDb {})}).filter(|refund| {- refund_details- .amount_filter- .as_ref()- .map_or(true, |amount| {- refund.refund_amount- >= MinorUnit::new(amount.start_amount.unwrap_or(i64::MIN))- && refund.refund_amount- <= MinorUnit::new(amount.end_amount.unwrap_or(i64::MAX))- })+ refund_details.amount_filter.as_ref().is_none_or(|amount| {+ refund.refund_amount >= MinorUnit::new(amount.start_amount.unwrap_or(i64::MIN))+ && refund.refund_amount+ <= MinorUnit::new(amount.end_amount.unwrap_or(i64::MAX))+ })}).filter(|refund| {unique_connectors.is_empty() || unique_connectors.contains(&refund.connector)@@ -1513,13 +1509,13 @@ impl RefundInterface for MockDb {refund_details.payment_id.clone()- .map_or(true, |id| id == refund.payment_id)+ .is_none_or(|id| id == refund.payment_id)}).filter(|refund| {refund_details.refund_id.clone()- .map_or(true, |id| id == refund.id)+ .is_none_or(|id| id == refund.id)}).filter(|refund| {refund@@ -1541,15 +1537,11 @@ impl RefundInterface for MockDb {})}).filter(|refund| {- refund_details- .amount_filter- .as_ref()- .map_or(true, |amount| {- refund.refund_amount- >= MinorUnit::new(amount.start_amount.unwrap_or(i64::MIN))- && refund.refund_amount- <= MinorUnit::new(amount.end_amount.unwrap_or(i64::MAX))- })+ refund_details.amount_filter.as_ref().is_none_or(|amount| {+ refund.refund_amount >= MinorUnit::new(amount.start_amount.unwrap_or(i64::MIN))+ && refund.refund_amount+ <= MinorUnit::new(amount.end_amount.unwrap_or(i64::MAX))+ })}).filter(|refund| {unique_connectors.is_empty() || unique_connectors.contains(&refund.connector)@@ -1720,13 +1712,13 @@ impl RefundInterface for MockDb {refund_details.payment_id.clone()- .map_or(true, |id| id == refund.payment_id)+ .is_none_or(|id| id == refund.payment_id)}).filter(|refund| {refund_details.refund_id.clone()- .map_or(true, |id| id == refund.refund_id)+ .is_none_or(|id| id == refund.refund_id)}).filter(|refund| {refund.profile_id.as_ref().is_some_and(|profile_id| {@@ -1747,15 +1739,11 @@ impl RefundInterface for MockDb {})}).filter(|refund| {- refund_details- .amount_filter- .as_ref()- .map_or(true, |amount| {- refund.refund_amount- >= MinorUnit::new(amount.start_amount.unwrap_or(i64::MIN))- && refund.refund_amount- <= MinorUnit::new(amount.end_amount.unwrap_or(i64::MAX))- })+ refund_details.amount_filter.as_ref().is_none_or(|amount| {+ refund.refund_amount >= MinorUnit::new(amount.start_amount.unwrap_or(i64::MIN))+ && refund.refund_amount+ <= MinorUnit::new(amount.end_amount.unwrap_or(i64::MAX))+ })}).filter(|refund| {unique_connectors.is_empty() || unique_connectors.contains(&refund.connector)@@ -1826,13 +1814,13 @@ impl RefundInterface for MockDb {refund_details.payment_id.clone()- .map_or(true, |id| id == refund.payment_id)+ .is_none_or(|id| id == refund.payment_id)}).filter(|refund| {refund_details.refund_id.clone()- .map_or(true, |id| id == refund.id)+ .is_none_or(|id| id == refund.id)}).filter(|refund| {refund@@ -1854,15 +1842,11 @@ impl RefundInterface for MockDb {})}).filter(|refund| {- refund_details- .amount_filter- .as_ref()- .map_or(true, |amount| {- refund.refund_amount- >= MinorUnit::new(amount.start_amount.unwrap_or(i64::MIN))- && refund.refund_amount- <= MinorUnit::new(amount.end_amount.unwrap_or(i64::MAX))- })+ refund_details.amount_filter.as_ref().is_none_or(|amount| {+ refund.refund_amount >= MinorUnit::new(amount.start_amount.unwrap_or(i64::MIN))+ && refund.refund_amount+ <= MinorUnit::new(amount.end_amount.unwrap_or(i64::MAX))+ })}).filter(|refund| {unique_connectors.is_empty() || unique_connectors.contains(&refund.connector)diff --git a/crates/router/src/utils/user_role.rs b/crates/router/src/utils/user_role.rsindex 67ed2127ea..7b5bd81678 100644--- a/crates/router/src/utils/user_role.rs+++ b/crates/router/src/utils/user_role.rs@@ -495,7 +495,7 @@ pub async fn fetch_user_roles_by_payload(.filter_map(|user_role| {let (_entity_id, entity_type) = user_role.get_entity_id_and_type()?;request_entity_type- .map_or(true, |req_entity_type| entity_type == req_entity_type)+ .is_none_or(|req_entity_type| entity_type == req_entity_type).then_some(user_role)}).collect::<HashSet<_>>())diff --git a/crates/storage_impl/src/utils.rs b/crates/storage_impl/src/utils.rsindex 9cfc683a3b..fd611911d6 100644--- a/crates/storage_impl/src/utils.rs+++ b/crates/storage_impl/src/utils.rs@@ -115,7 +115,7 @@ wherelet limit_satisfies = |len: usize, limit: i64| {TryInto::try_into(limit).ok()- .map_or(true, |val: usize| len >= val)+ .is_none_or(|val: usize| len >= val)};let redis_output = redis_fut.await;