From 8a9adce0ea526fc83f2de5550c281268dd16d0de Mon Sep 17 00:00:00 2001 From: Piotr Dulikowski Date: Mon, 11 Sep 2023 09:03:57 +0200 Subject: [PATCH] utils: remove unzip_option `unzip_option` was a workaround for missing `Option::unzip()`, which was introduced in Rust v1.66.0. We finally bumped the MSRV to 1.66.0, so `unzip_option` can be removed and replaced with the real thing. --- scylla/src/transport/iterator.rs | 3 +-- scylla/src/transport/session.rs | 8 ++++---- scylla/src/utils/mod.rs | 8 -------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/scylla/src/transport/iterator.rs b/scylla/src/transport/iterator.rs index a9f5a7ec5b..e9389992ed 100644 --- a/scylla/src/transport/iterator.rs +++ b/scylla/src/transport/iterator.rs @@ -38,7 +38,6 @@ use crate::transport::load_balancing::{self, RoutingInfo}; use crate::transport::metrics::Metrics; use crate::transport::retry_policy::{QueryInfo, RetryDecision, RetrySession}; use crate::transport::{Node, NodeRef}; -use crate::utils::unzip_option; use tracing::{trace, trace_span, warn, Instrument}; use uuid::Uuid; @@ -246,7 +245,7 @@ impl RowIterator { prepared_ref.get_partitioner_name(), values_ref, ) { - Ok(res) => unzip_option(res), + Ok(res) => res.unzip(), Err(err) => { let (proof, _res) = ProvingSender::from(sender).send(Err(err)).await; return proof; diff --git a/scylla/src/transport/session.rs b/scylla/src/transport/session.rs index 790f840400..35ff25475f 100644 --- a/scylla/src/transport/session.rs +++ b/scylla/src/transport/session.rs @@ -7,7 +7,6 @@ use crate::cloud::CloudConfig; use crate::history; use crate::history::HistoryListener; use crate::utils::pretty::{CommaSeparatedDisplayer, CqlValueDisplayer}; -use crate::utils::unzip_option; use arc_swap::ArcSwapOption; use async_trait::async_trait; use bytes::Bytes; @@ -937,11 +936,12 @@ impl Session { let values_ref = &serialized_values; let paging_state_ref = &paging_state; - let (partition_key, token) = - unzip_option(prepared.extract_partition_key_and_calculate_token( + let (partition_key, token) = prepared + .extract_partition_key_and_calculate_token( prepared.get_partitioner_name(), &serialized_values, - )?); + )? + .unzip(); let execution_profile = prepared .get_execution_profile_handle() diff --git a/scylla/src/utils/mod.rs b/scylla/src/utils/mod.rs index 9399e33266..c83adbf7e7 100644 --- a/scylla/src/utils/mod.rs +++ b/scylla/src/utils/mod.rs @@ -2,11 +2,3 @@ pub(crate) mod parse; pub(crate) mod pretty; pub mod test_utils; - -// FIXME: replace this with `Option::unzip()` once MSRV is bumped to at least 1.66 -pub(crate) fn unzip_option(opt: Option<(T, U)>) -> (Option, Option) { - match opt { - Some((a, b)) => (Some(a), Some(b)), - None => (None, None), - } -}