Skip to content

Instantly share code, notes, and snippets.

@interacsion
interacsion / group_by.rs
Created February 17, 2024 18:28
Rust `group_by` (Reader discretion is advised)
use core::cell::RefCell;
use std::collections::{BTreeMap, VecDeque};
use std::rc::Rc;
pub trait GroupBy<Item> {
fn group(self) -> impl Iterator<Item = (Item, impl Iterator<Item = Item>)>
where
Item: PartialEq + Copy;
fn group_by<Key, KeyFn>(