use {
crate::window::Window,
ventana_hal::{
event::Event,
window::BackendEventIterator,
},
};
impl Window {
pub fn iter<'w>(&'w self) -> EventIterator<'w> {
EventIterator(self.window.iter())
}
}
pub struct EventIterator<'w>(Box<dyn BackendEventIterator<'w> + 'w>);
impl<'a> Iterator for EventIterator<'a> {
type Item = Event;
fn next(&mut self) -> Option<Self::Item> {
self.0.next()
}
}
impl<'a> IntoIterator for &'a Window {
type IntoIter = EventIterator<'a>;
type Item = Event;
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}