Remove Drawable and rename State to Program

This commit is contained in:
Héctor Ramón Jiménez 2020-04-28 06:24:12 +02:00
parent 7f1e7aea07
commit 2539042b71
11 changed files with 202 additions and 304 deletions

View file

@ -0,0 +1,22 @@
use crate::canvas::{Event, Geometry, Size};
pub trait Program<Message> {
fn update(&mut self, _event: Event, _bounds: Size) -> Option<Message> {
None
}
fn draw(&self, bounds: Size) -> Vec<Geometry>;
}
impl<T, Message> Program<Message> for &mut T
where
T: Program<Message>,
{
fn update(&mut self, event: Event, bounds: Size) -> Option<Message> {
T::update(self, event, bounds)
}
fn draw(&self, bounds: Size) -> Vec<Geometry> {
T::draw(self, bounds)
}
}