1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
use std::collections::LinkedList; pub struct Events<T>(LinkedList<T>); impl<T> Events<T> { #[inline] pub fn new() -> Self { Events(LinkedList::new()) } #[inline] pub fn push(&mut self, event: T) { self.0.push_front(event); } } impl<'a, T> Iterator for &'a mut Events<T> { type Item = T; #[inline] fn next(&mut self) -> Option<Self::Item> { self.0.pop_back() } }