use crate::canvas::{Cursor, Event, Geometry}; use iced_native::{MouseCursor, Rectangle}; pub trait Program { fn update( &mut self, _event: Event, _bounds: Rectangle, _cursor: Cursor, ) -> Option { None } fn draw(&self, bounds: Rectangle, cursor: Cursor) -> Vec; fn mouse_cursor(&self, _bounds: Rectangle, _cursor: Cursor) -> MouseCursor { MouseCursor::default() } } impl Program for &mut T where T: Program, { fn update( &mut self, event: Event, bounds: Rectangle, cursor: Cursor, ) -> Option { T::update(self, event, bounds, cursor) } fn draw(&self, bounds: Rectangle, cursor: Cursor) -> Vec { T::draw(self, bounds, cursor) } fn mouse_cursor(&self, bounds: Rectangle, cursor: Cursor) -> MouseCursor { T::mouse_cursor(self, bounds, cursor) } }