Replace .insert_resource(T::default()) calls with init_resource::<T>() (#2807)

# Objective

I added the [INSERT_RESOURCE_WITH_DEFAULT](https://minersebas.github.io/bevy_lint/bevy_lint/static.INSERT_RESOURCE_WITH_DEFAULT.html) Lint to [bevy_lint](https://github.com/MinerSebas/bevy_lint) and while Testing it on bevy itself, I found several places where the Lint correctly triggered.



## Solution

Replace `.insert_resource(T::default())` calls with `init_resource::<T>()`
This commit is contained in:
MinerSebas 2021-09-13 14:02:28 +00:00
parent e74f7a7335
commit 9effc3e9b3
4 changed files with 4 additions and 4 deletions

View file

@ -334,7 +334,7 @@ impl App {
where
T: Component,
{
self.insert_resource(Events::<T>::default())
self.init_resource::<Events<T>>()
.add_system_to_stage(CoreStage::First, Events::<T>::update_system)
}

View file

@ -42,7 +42,7 @@ impl Plugin for TextPlugin {
app.add_asset::<Font>()
.add_asset::<FontAtlasSet>()
.init_asset_loader::<FontLoader>()
.insert_resource(DefaultTextPipeline::default())
.init_resource::<DefaultTextPipeline>()
.add_system_to_stage(CoreStage::PostUpdate, text2d_system)
.add_system_to_stage(RenderStage::Draw, text2d::draw_text2d_system);
}

View file

@ -4,7 +4,7 @@ fn main() {
App::new()
.insert_resource(Msaa { samples: 4 })
.add_plugins(DefaultPlugins)
.insert_resource(SceneInstance::default())
.init_resource::<SceneInstance>()
.add_startup_system(setup)
.add_system(scene_update)
.add_system(move_scene_entities)

View file

@ -3,7 +3,7 @@ use bevy::{log::info, prelude::*};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.insert_resource(Countdown::default())
.init_resource::<Countdown>()
.add_startup_system(setup_system)
.add_system(countdown_system)
.add_system(timer_system)