mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
297 B
21 lines
297 B
3 years ago
|
pub trait Draw {
|
||
|
fn draw(&self);
|
||
|
}
|
||
|
|
||
|
// ANCHOR: here
|
||
|
pub struct Screen<T: Draw> {
|
||
|
pub components: Vec<T>,
|
||
|
}
|
||
|
|
||
|
impl<T> Screen<T>
|
||
|
where
|
||
|
T: Draw,
|
||
|
{
|
||
|
pub fn run(&self) {
|
||
|
for component in self.components.iter() {
|
||
|
component.draw();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
// ANCHOR_END: here
|