Skip to content

Commit

Permalink
Replace .insert_resource(T::default()) calls with `init_resource::<…
Browse files Browse the repository at this point in the history
…T>()` (bevyengine#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>()`
  • Loading branch information
MinerSebas committed Sep 13, 2021
1 parent e74f7a7 commit 9effc3e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_text/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/3d/update_gltf_scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/ecs/timers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9effc3e

Please sign in to comment.