blob: f97634e4dc0c763b00da17511b2243667aec12a8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
use crate::canvas::Frame;
pub trait Layer: std::fmt::Debug {}
use std::marker::PhantomData;
use std::sync::{Arc, Weak};
#[derive(Debug)]
pub struct Cached<T: Drawable> {
input: PhantomData<T>,
}
impl<T> Cached<T>
where
T: Drawable + std::fmt::Debug,
{
pub fn new() -> Self {
Cached { input: PhantomData }
}
pub fn clear(&mut self) {}
pub fn with<'a>(&'a self, input: &'a T) -> impl Layer + 'a {
Bind {
cache: self,
input: input,
}
}
}
#[derive(Debug)]
struct Bind<'a, T: Drawable> {
cache: &'a Cached<T>,
input: &'a T,
}
impl<'a, T> Layer for Bind<'a, T> where T: Drawable + std::fmt::Debug {}
pub trait Drawable {
fn draw(&self, frame: &mut Frame);
}
|