diff --git a/components/engine_traits/src/flush.rs b/components/engine_traits/src/flush.rs index 8590236e126..46b1877a703 100644 --- a/components/engine_traits/src/flush.rs +++ b/components/engine_traits/src/flush.rs @@ -119,7 +119,7 @@ impl SstApplyState { for sst in ssts { let cf_index = data_cf_offset(sst.get_cf_name()); if let Some(metas) = sst_list.get_mut(cf_index) { - metas.drain_filter(|entry| entry.sst.get_uuid() == sst.get_uuid()); + metas.retain(|entry| entry.sst.get_uuid() != sst.get_uuid()); } } } diff --git a/components/engine_traits/src/lib.rs b/components/engine_traits/src/lib.rs index 53708994561..64818d8c847 100644 --- a/components/engine_traits/src/lib.rs +++ b/components/engine_traits/src/lib.rs @@ -254,7 +254,6 @@ #![feature(linked_list_cursors)] #![feature(let_chains)] #![feature(str_split_as_str)] -#![feature(drain_filter)] #[macro_use(fail_point)] extern crate fail; diff --git a/components/raftstore/src/lib.rs b/components/raftstore/src/lib.rs index 1db5f79d226..33edbf313d5 100644 --- a/components/raftstore/src/lib.rs +++ b/components/raftstore/src/lib.rs @@ -5,7 +5,7 @@ #![feature(div_duration)] #![feature(min_specialization)] #![feature(box_patterns)] -#![feature(hash_drain_filter)] +#![feature(hash_extract_if)] #![feature(let_chains)] #![feature(assert_matches)] #![feature(type_alias_impl_trait)] diff --git a/components/raftstore/src/store/snap.rs b/components/raftstore/src/store/snap.rs index e7e7c6ccb10..efef7f47ee2 100644 --- a/components/raftstore/src/store/snap.rs +++ b/components/raftstore/src/store/snap.rs @@ -2174,7 +2174,7 @@ impl TabletSnapManager { .stats .lock() .unwrap() - .drain_filter(|_, (_, stat)| stat.get_region_id() > 0) + .extract_if(|_, (_, stat)| stat.get_region_id() > 0) .map(|(_, (_, stat))| stat) .filter(|stat| stat.get_total_duration_sec() > 1) .collect(); diff --git a/components/raftstore/src/store/txn_ext.rs b/components/raftstore/src/store/txn_ext.rs index 0091fd4e7bb..951d3bfe783 100644 --- a/components/raftstore/src/store/txn_ext.rs +++ b/components/raftstore/src/store/txn_ext.rs @@ -84,7 +84,7 @@ pub struct PeerPessimisticLocks { /// likely to be proposed successfully, while the leader will need at /// least another round to receive the transfer leader message from the /// transferee. - /// + /// /// - Split region The lock with the deleted mark SHOULD be moved to new /// regions on region split. Considering the following cases with /// different orders: 1. Propose write -> propose split -> apply write -> @@ -244,7 +244,7 @@ impl PeerPessimisticLocks { // Locks that are marked deleted still need to be moved to the new regions, // and the deleted mark should also be cleared. // Refer to the comment in `PeerPessimisticLocks` for details. - let removed_locks = self.map.drain_filter(|key, _| { + let removed_locks = self.map.extract_if(|key, _| { let key = &**key.as_encoded(); let (start_key, end_key) = (derived.get_start_key(), derived.get_end_key()); key < start_key || (!end_key.is_empty() && key >= end_key) diff --git a/components/resource_metering/src/lib.rs b/components/resource_metering/src/lib.rs index ba8e2174e19..7b437ea4303 100644 --- a/components/resource_metering/src/lib.rs +++ b/components/resource_metering/src/lib.rs @@ -2,7 +2,7 @@ // TODO(mornyx): crate doc. -#![feature(hash_drain_filter)] +#![feature(hash_extract_if)] #![feature(core_intrinsics)] use std::{ diff --git a/components/resource_metering/src/model.rs b/components/resource_metering/src/model.rs index 6f7118ef9e1..03cd500eb2e 100644 --- a/components/resource_metering/src/model.rs +++ b/components/resource_metering/src/model.rs @@ -87,7 +87,7 @@ impl RawRecords { pdqselect::select_by(&mut buf, k, |a, b| b.cmp(a)); let kth = buf[k]; // Evict records with cpu time less or equal than `kth` - let evicted_records = self.records.drain_filter(|_, r| r.cpu_time <= kth); + let evicted_records = self.records.extract_if(|_, r| r.cpu_time <= kth); // Record evicted into others for (_, record) in evicted_records { others.merge(&record); diff --git a/src/config/mod.rs b/src/config/mod.rs index c0c2a679b5a..43f6c447443 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -2064,7 +2064,7 @@ impl ConfigManager for DbConfigManger { self.cfg.update(change.clone())?; let change_str = format!("{:?}", change); let mut change: Vec<(String, ConfigValue)> = change.into_iter().collect(); - let cf_config = change.drain_filter(|(name, _)| name.ends_with("cf")); + let cf_config = change.extract_if(|(name, _)| name.ends_with("cf")); for (cf_name, cf_change) in cf_config { if let ConfigValue::Module(mut cf_change) = cf_change { // defaultcf -> default @@ -2098,7 +2098,7 @@ impl ConfigManager for DbConfigManger { } if let Some(rate_bytes_config) = change - .drain_filter(|(name, _)| name == "rate_bytes_per_sec") + .extract_if(|(name, _)| name == "rate_bytes_per_sec") .next() { let rate_bytes_per_sec: ReadableSize = rate_bytes_config.1.into(); @@ -2107,7 +2107,7 @@ impl ConfigManager for DbConfigManger { } if let Some(rate_bytes_config) = change - .drain_filter(|(name, _)| name == "rate_limiter_auto_tuned") + .extract_if(|(name, _)| name == "rate_limiter_auto_tuned") .next() { let rate_limiter_auto_tuned: bool = rate_bytes_config.1.into(); @@ -2116,7 +2116,7 @@ impl ConfigManager for DbConfigManger { } if let Some(size) = change - .drain_filter(|(name, _)| name == "write_buffer_limit") + .extract_if(|(name, _)| name == "write_buffer_limit") .next() { let size: ReadableSize = size.1.into(); @@ -2124,14 +2124,14 @@ impl ConfigManager for DbConfigManger { } if let Some(f) = change - .drain_filter(|(name, _)| name == "write_buffer_flush_oldest_first") + .extract_if(|(name, _)| name == "write_buffer_flush_oldest_first") .next() { self.db.set_flush_oldest_first(f.1.into())?; } if let Some(background_jobs_config) = change - .drain_filter(|(name, _)| name == "max_background_jobs") + .extract_if(|(name, _)| name == "max_background_jobs") .next() { let max_background_jobs: i32 = background_jobs_config.1.into(); @@ -2139,7 +2139,7 @@ impl ConfigManager for DbConfigManger { } if let Some(background_subcompactions_config) = change - .drain_filter(|(name, _)| name == "max_sub_compactions") + .extract_if(|(name, _)| name == "max_sub_compactions") .next() { let max_subcompactions: u32 = background_subcompactions_config.1.into(); @@ -2148,7 +2148,7 @@ impl ConfigManager for DbConfigManger { } if let Some(background_flushes_config) = change - .drain_filter(|(name, _)| name == "max_background_flushes") + .extract_if(|(name, _)| name == "max_background_flushes") .next() { let max_background_flushes: i32 = background_flushes_config.1.into(); diff --git a/src/lib.rs b/src/lib.rs index 6d1cc515907..31a3f5c71d5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,7 +23,7 @@ #![feature(proc_macro_hygiene)] #![feature(min_specialization)] #![feature(box_patterns)] -#![feature(drain_filter)] +#![feature(extract_if)] #![feature(deadline_api)] #![feature(let_chains)] #![feature(read_buf)]