Skip to content

Instantly share code, notes, and snippets.

View Thell's full-sized avatar

Thell 'Bo' Fowler Thell

  • Pyrapat Inc.
  • Arkansas, USA
View GitHub Profile
@Thell
Thell / enumerated_retain.rs
Last active March 20, 2023 06:40
Impls for retain methods with enumerate and with access to the remaining elements for predicate.
trait EnumeratedRetain<T> {
fn retain_enumerate<F>(&mut self, f: F)
where
F: FnMut(usize, &T) -> bool;
}
impl<T> EnumeratedRetain<T> for Vec<T> {
fn retain_enumerate<F>(&mut self, mut f: F)
where
F: FnMut(usize, &T) -> bool,