Skip to content

Instantly share code, notes, and snippets.

View interacsion's full-sized avatar

Mai interacsion

View GitHub Profile
@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>(