Skip to content

impl default for canvas cache#267

Merged
hecrj merged 1 commit into
iced-rs:masterfrom
robjtede:improve/canvas-cache-default
Apr 8, 2020
Merged

impl default for canvas cache#267
hecrj merged 1 commit into
iced-rs:masterfrom
robjtede:improve/canvas-cache-default

Conversation

@robjtede

@robjtede robjtede commented Apr 6, 2020

Copy link
Copy Markdown
Contributor

Previously needed to write the full Default implementation:

#[derive(Debug)]
pub struct AppState {
    all_data: State,
    current_frame_data: D,
    current_frame_canvas_cache: canvas::layer::Cache<D>,
}

impl Default for AppState {
    fn default() -> Self {
        Self {
            all_data: Default::default(),
            current_frame_data: Default::default(),
            current_frame_canvas_cache: iced::widget::canvas::layer::Cache::new(),
        }
    }
}

Now deriving a default application state is possible:

#[derive(Debug, Default)]
pub struct AppState {
    all_data: State,
    current_frame_data: D,
    current_frame_canvas_cache: canvas::layer::Cache<D>,
}

@hecrj hecrj added the feature New feature or request label Apr 6, 2020
@hecrj hecrj added this to the 0.1.1 milestone Apr 6, 2020
Comment thread wgpu/src/widget/canvas/layer/cache.rs Outdated
@robjtede robjtede force-pushed the improve/canvas-cache-default branch from eae6820 to 6e7769b Compare April 8, 2020 22:08

@hecrj hecrj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 🎉 Thank you!

@hecrj hecrj merged commit d51b501 into iced-rs:master Apr 8, 2020
@robjtede robjtede deleted the improve/canvas-cache-default branch April 8, 2020 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants