Improve Debug implementation of cache::State

This commit is contained in:
Héctor Ramón Jiménez 2020-03-04 21:56:59 +01:00
parent 012b4adec7
commit b6926d9ab4

View File

@ -21,7 +21,6 @@ pub struct Cache<T: Drawable> {
state: RefCell<State>,
}
#[derive(Debug)]
enum State {
Empty,
Filled {
@ -99,3 +98,17 @@ where
mesh
}
}
impl std::fmt::Debug for State {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
State::Empty => write!(f, "Empty"),
State::Filled { mesh, bounds } => f
.debug_struct("Filled")
.field("vertices", &mesh.vertices.len())
.field("indices", &mesh.indices.len())
.field("bounds", bounds)
.finish(),
}
}
}