Skip to content

Commit bdfa6c8

Browse files
authored
Move EntityHash related types into bevy_ecs (#11498)
# Objective Reduce the size of `bevy_utils` (bevyengine/bevy#11478) ## Solution Move `EntityHash` related types into `bevy_ecs`. This also allows us access to `Entity`, which means we no longer need `EntityHashMap`'s first generic argument. --- ## Changelog - Moved `bevy::utils::{EntityHash, EntityHasher, EntityHashMap, EntityHashSet}` into `bevy::ecs::entity::hash` . - Removed `EntityHashMap`'s first generic argument. It is now hardcoded to always be `Entity`. ## Migration Guide - Uses of `bevy::utils::{EntityHash, EntityHasher, EntityHashMap, EntityHashSet}` now have to be imported from `bevy::ecs::entity::hash`. - Uses of `EntityHashMap` no longer have to specify the first generic parameter. It is now hardcoded to always be `Entity`.
1 parent e92bd51 commit bdfa6c8

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/accessibility.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ use bevy_a11y::{
1515
use bevy_a11y::{ActionRequest as ActionRequestWrapper, ManageAccessibilityUpdates};
1616
use bevy_app::{App, Plugin, PostUpdate};
1717
use bevy_derive::{Deref, DerefMut};
18+
use bevy_ecs::entity::EntityHashMap;
1819
use bevy_ecs::{
1920
prelude::{DetectChanges, Entity, EventReader, EventWriter},
2021
query::With,
2122
schedule::IntoSystemConfigs,
2223
system::{NonSend, NonSendMut, Query, Res, ResMut, Resource},
2324
};
2425
use bevy_hierarchy::{Children, Parent};
25-
use bevy_utils::EntityHashMap;
2626
use bevy_window::{PrimaryWindow, Window, WindowClosed};
2727

2828
/// Maps window entities to their `AccessKit` [`Adapter`]s.
2929
#[derive(Default, Deref, DerefMut)]
30-
pub struct AccessKitAdapters(pub EntityHashMap<Entity, Adapter>);
30+
pub struct AccessKitAdapters(pub EntityHashMap<Adapter>);
3131

3232
/// Maps window entities to their respective [`WinitActionHandler`]s.
3333
#[derive(Resource, Default, Deref, DerefMut)]
34-
pub struct WinitActionHandlers(pub EntityHashMap<Entity, WinitActionHandler>);
34+
pub struct WinitActionHandlers(pub EntityHashMap<WinitActionHandler>);
3535

3636
/// Forwards `AccessKit` [`ActionRequest`]s from winit to an event channel.
3737
#[derive(Clone, Default, Deref, DerefMut)]

src/winit_windows.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use bevy_a11y::{
55
};
66
use bevy_ecs::entity::Entity;
77

8-
use bevy_utils::{tracing::warn, EntityHashMap, HashMap};
8+
use bevy_ecs::entity::EntityHashMap;
9+
use bevy_utils::{tracing::warn, HashMap};
910
use bevy_window::{CursorGrabMode, Window, WindowMode, WindowPosition, WindowResolution};
1011

1112
use winit::{
@@ -25,7 +26,7 @@ pub struct WinitWindows {
2526
/// Stores [`winit`] windows by window identifier.
2627
pub windows: HashMap<winit::window::WindowId, winit::window::Window>,
2728
/// Maps entities to `winit` window identifiers.
28-
pub entity_to_winit: EntityHashMap<Entity, winit::window::WindowId>,
29+
pub entity_to_winit: EntityHashMap<winit::window::WindowId>,
2930
/// Maps `winit` window identifiers to entities.
3031
pub winit_to_entity: HashMap<winit::window::WindowId, Entity>,
3132
// Many `winit` window functions (e.g. `set_window_icon`) can only be called on the main thread.

0 commit comments

Comments
 (0)