mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-09-19 13:36:42 +02:00
more space/ and draw/ modules
- 26 errors and 16 doctest fails - getting there, perpetually
This commit is contained in:
parent
42a1807c2b
commit
145047b7ff
15 changed files with 269 additions and 232 deletions
16
src/draw/thunk.rs
Normal file
16
src/draw/thunk.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
use super::*;
|
||||
|
||||
pub const fn thunk <T: Screen, F: FnOnce(&mut T)->Usually<XYWH<T::Unit>>> (draw: F) -> Thunk<T, F> {
|
||||
Thunk(draw, std::marker::PhantomData)
|
||||
}
|
||||
|
||||
/// Because we can't implement [Draw] for `F: FnOnce...` without conflicts.
|
||||
pub struct Thunk<T: Screen, F: FnOnce(&mut T)->Usually<XYWH<T::Unit>>>(
|
||||
pub F,
|
||||
std::marker::PhantomData<T>
|
||||
);
|
||||
impl<T: Screen, F: FnOnce(&mut T)->Usually<XYWH<T::Unit>>> Draw<T> for Thunk<T, F> {
|
||||
fn draw (self, to: &mut T) -> Usually<XYWH<T::Unit>> {
|
||||
(self.0)(to)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue