mirror of
https://github.com/ricoriedel/wipe.git
synced 2024-11-22 16:06:38 +00:00
Replace dyn with generic
This commit is contained in:
parent
d600c133bc
commit
7925af1bdc
@ -15,8 +15,8 @@ pub trait Renderer {
|
|||||||
fn purge(&mut self) -> Result<(), Error>;
|
fn purge(&mut self) -> Result<(), Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WriteRenderer {
|
pub struct WriteRenderer<T> {
|
||||||
out: Box<dyn Write>,
|
out: T,
|
||||||
array: Array2D<Cell>,
|
array: Array2D<Cell>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,8 +31,8 @@ impl Default for Cell {
|
|||||||
fn default() -> Self { Cell::Keep }
|
fn default() -> Self { Cell::Keep }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WriteRenderer {
|
impl<T> WriteRenderer<T> {
|
||||||
pub fn new(out: Box<dyn Write>, width: usize, height: usize) -> Self {
|
pub fn new(out: T, width: usize, height: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
out,
|
out,
|
||||||
array: Array2D::new(width, height)
|
array: Array2D::new(width, height)
|
||||||
@ -40,7 +40,7 @@ impl WriteRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Renderer for WriteRenderer {
|
impl<T: Write> Renderer for WriteRenderer<T> {
|
||||||
fn width(&self) -> usize {
|
fn width(&self) -> usize {
|
||||||
self.array.width()
|
self.array.width()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user