Skip to content

Commit

Permalink
chore: rename drain_filter to extract_if
Browse files Browse the repository at this point in the history
sync w/ upstream

References:
* rust-lang/rust#104455
* rust-lang/rust#70530

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
  • Loading branch information
rwestphal committed Jan 25, 2024
1 parent 8f364d6 commit d61452a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion holo-northbound/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ where
// Move to a separate vector the changes that need to be relayed.
let callbacks = P::callbacks().unwrap();
let relayed_changes = changes
.drain_filter(|(cb_key, _)| callbacks.0.get(cb_key).is_none())
.extract_if(|(cb_key, _)| callbacks.0.get(cb_key).is_none())
.collect();

// Process local changes.
Expand Down
2 changes: 1 addition & 1 deletion holo-northbound/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// See LICENSE for license details.
//

#![feature(drain_filter)]
#![feature(extract_if)]
#![warn(rust_2018_idioms)]
#![allow(type_alias_bounds)]
#![allow(clippy::too_many_arguments)]
Expand Down
2 changes: 1 addition & 1 deletion holo-ospf/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ where
// retransmission lists.
for lse_idx in lsdb
.maxage_lsas
.drain_filter(|lse_idx| {
.extract_if(|lse_idx| {
let lse = &arenas.lsa_entries[*lse_idx];
!arenas.neighbors.iter().any(|(_, nbr)| {
nbr.lists
Expand Down
2 changes: 1 addition & 1 deletion holo-ospf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)]
#![allow(clippy::single_match, clippy::too_many_arguments)]
#![allow(type_alias_bounds)]
#![feature(btree_drain_filter, hash_drain_filter, ip, let_chains, lazy_cell)]
#![feature(btree_extract_if, hash_extract_if, ip, let_chains, lazy_cell)]

pub mod area;
pub mod collections;
Expand Down
8 changes: 4 additions & 4 deletions holo-ospf/src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pub(crate) fn update_rib_partial<V>(
// Check for intra-area changes.
if !partial.intra.is_empty() {
// Remove affected intra-area routes from the RIB.
old_rib.extend(rib.drain_filter(|prefix, route| {
old_rib.extend(rib.extract_if(|prefix, route| {
partial.intra.contains(prefix)
&& route.path_type == PathType::IntraArea
}));
Expand All @@ -235,7 +235,7 @@ pub(crate) fn update_rib_partial<V>(
// Check for inter-area changes.
if !partial.inter_network.is_empty() {
// Remove affected inter-area routes from the RIB.
old_rib.extend(rib.drain_filter(|prefix, route| {
old_rib.extend(rib.extract_if(|prefix, route| {
partial.inter_network.contains(prefix)
&& route.path_type == PathType::InterArea
}));
Expand Down Expand Up @@ -273,7 +273,7 @@ pub(crate) fn update_rib_partial<V>(
}

// Remove affected inter-area routes from the routers RIB.
area.state.routers.drain_filter(|router_id, route| {
let _ = area.state.routers.extract_if(|router_id, route| {
partial.inter_router.contains(router_id)
&& route.path_type == PathType::InterArea
});
Expand All @@ -294,7 +294,7 @@ pub(crate) fn update_rib_partial<V>(
let reevaluate_all = !partial.inter_router.is_empty();

// Remove affected external routes from the RIB.
old_rib.extend(rib.drain_filter(|prefix, route| {
old_rib.extend(rib.extract_if(|prefix, route| {
(reevaluate_all || partial.external.contains(prefix))
&& matches!(
route.path_type,
Expand Down

0 comments on commit d61452a

Please sign in to comment.