Skip to content

Commit

Permalink
find_remove added
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-kolarik committed Sep 18, 2023
1 parent 887faef commit aea28ca
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/futures_signals_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ pub trait MutableVecExt<A> {
A: Clone,
O: FnMut(&A) -> cmp::Ordering;

fn find_remove<P>(&self, p: P) -> bool
where
P: FnMut(&A) -> bool;

fn signal_vec_filter<P>(&self, p: P) -> Filter<MutableSignalVec<A>, P>
where
A: Copy,
Expand Down Expand Up @@ -315,6 +319,19 @@ impl<A> MutableVecExt<A> for MutableVec<A> {
}
}

fn find_remove<P>(&self, p: P) -> bool
where
P: FnMut(&A) -> bool,
{
let mut lock = self.lock_mut();
if let Some(index) = lock.iter().position(p) {
lock.remove(index);
true
} else {
false
}
}

fn signal_vec_filter<P>(&self, p: P) -> Filter<MutableSignalVec<A>, P>
where
A: Copy,
Expand Down

0 comments on commit aea28ca

Please sign in to comment.