Skip to content

Commit eae6820

Browse files
committed
impl default for canvas cache
1 parent ad0a6c4 commit eae6820

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

wgpu/src/widget/canvas/layer/cache.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::{cell::RefCell, marker::PhantomData, sync::Arc};
1313
///
1414
/// [`Layer`]: ../trait.Layer.html
1515
/// [`Cache`]: struct.Cache.html
16-
#[derive(Debug)]
16+
#[derive(Debug, Default)]
1717
pub struct Cache<T: Drawable> {
1818
input: PhantomData<T>,
1919
state: RefCell<State>,
@@ -27,6 +27,12 @@ enum State {
2727
},
2828
}
2929

30+
impl Default for State {
31+
fn default() -> Self {
32+
State::Empty
33+
}
34+
}
35+
3036
impl<T> Cache<T>
3137
where
3238
T: Drawable + std::fmt::Debug,
@@ -37,7 +43,7 @@ where
3743
pub fn new() -> Self {
3844
Cache {
3945
input: PhantomData,
40-
state: RefCell::new(State::Empty),
46+
state: RefCell::new(State::default()),
4147
}
4248
}
4349

0 commit comments

Comments
 (0)