Skip to content

Commit

Permalink
Remove unnecessary ResMut in examples (bevyengine#10879)
Browse files Browse the repository at this point in the history
# Objective

- Examples containing `ResMut`s that are never mutated can be confusing
for readers.

## Solution

- Changes them to `Res`.
  • Loading branch information
akimakinai authored Dec 5, 2023
1 parent 9da65b1 commit f90248b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/2d/texture_atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn load_textures(mut commands: Commands, asset_server: Res<AssetServer>) {

fn check_textures(
mut next_state: ResMut<NextState<AppState>>,
rpg_sprite_folder: ResMut<RpgSpriteFolder>,
rpg_sprite_folder: Res<RpgSpriteFolder>,
mut events: EventReader<AssetEvent<LoadedFolder>>,
) {
// Advance the `AppState` once all sprite handles have been loaded by the `AssetServer`
Expand Down
2 changes: 1 addition & 1 deletion examples/3d/generate_custom_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {

fn setup(
mut commands: Commands,
asset_server: ResMut<AssetServer>,
asset_server: Res<AssetServer>,
mut materials: ResMut<Assets<StandardMaterial>>,
mut meshes: ResMut<Assets<Mesh>>,
) {
Expand Down
2 changes: 1 addition & 1 deletion examples/asset/custom_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn setup(mut state: ResMut<State>, asset_server: Res<AssetServer>) {
state.handle = asset_server.load("data/asset.custom");
}

fn print_on_load(mut state: ResMut<State>, custom_assets: ResMut<Assets<CustomAsset>>) {
fn print_on_load(mut state: ResMut<State>, custom_assets: Res<Assets<CustomAsset>>) {
let custom_asset = custom_assets.get(&state.handle);
if state.printed || custom_asset.is_none() {
return;
Expand Down
2 changes: 1 addition & 1 deletion examples/ui/ui_scaling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn main() {
.run();
}

fn setup(mut commands: Commands, asset_server: ResMut<AssetServer>) {
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera2dBundle::default());

let text_style = TextStyle {
Expand Down

0 comments on commit f90248b

Please sign in to comment.