Skip to content

Commit

Permalink
Replace derive(Default) with impl in AssetCountDiagnosticsPlugin (bev…
Browse files Browse the repository at this point in the history
…yengine#2077)

Hi, ran into this problem with the derive macro.

It fails trying to derive the Default trait when the asset does not implements it also. This is unnecessary because this plugin does not need that from the asset type, just needs to create the phantom data.
  • Loading branch information
Jbat1Jumper committed May 2, 2021
1 parent 3af3334 commit 5390be0
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ use bevy_diagnostic::{Diagnostic, DiagnosticId, Diagnostics};
use bevy_ecs::system::{IntoSystem, Res, ResMut};

/// Adds "asset count" diagnostic to an App
#[derive(Default)]
pub struct AssetCountDiagnosticsPlugin<T: Asset> {
marker: std::marker::PhantomData<T>,
}

impl<T: Asset> Default for AssetCountDiagnosticsPlugin<T> {
fn default() -> Self {
Self {
marker: std::marker::PhantomData,
}
}
}

impl<T: Asset> Plugin for AssetCountDiagnosticsPlugin<T> {
fn build(&self, app: &mut AppBuilder) {
app.add_startup_system(Self::setup_system.system())
Expand Down

0 comments on commit 5390be0

Please sign in to comment.