Remove Layer trait and simplify Canvas

This commit is contained in:
Héctor Ramón Jiménez 2020-04-19 21:55:23 +02:00
parent bb424e54c5
commit 592cc68506
9 changed files with 181 additions and 174 deletions

View file

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