Skip to content

Commit f57c7a4

Browse files
authored
reexport entity set collections in entity module (#18413)
# Objective Unlike for their helper typers, the import paths for `unique_array::UniqueEntityArray`, `unique_slice::UniqueEntitySlice`, `unique_vec::UniqueEntityVec`, `hash_set::EntityHashSet`, `hash_map::EntityHashMap`, `index_set::EntityIndexSet`, `index_map::EntityIndexMap` are quite redundant. When looking at the structure of `hashbrown`, we can also see that while both `HashSet` and `HashMap` have their own modules, the main types themselves are re-exported to the crate level. ## Solution Re-export the types in their shared `entity` parent module, and simplify the imports where they're used.
1 parent b0c4467 commit f57c7a4

File tree

42 files changed

+81
-76
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+81
-76
lines changed

benches/benches/bevy_ecs/world/entity_hash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bevy_ecs::entity::{hash_set::EntityHashSet, Entity};
1+
use bevy_ecs::entity::{Entity, EntityHashSet};
22
use criterion::{BenchmarkId, Criterion, Throughput};
33
use rand::{Rng, SeedableRng};
44
use rand_chacha::ChaCha8Rng;

crates/bevy_core_pipeline/src/oit/resolve/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use bevy_app::Plugin;
66
use bevy_asset::{load_internal_asset, weak_handle, Handle};
77
use bevy_derive::Deref;
88
use bevy_ecs::{
9-
entity::{hash_map::EntityHashMap, hash_set::EntityHashSet},
9+
entity::{EntityHashMap, EntityHashSet},
1010
prelude::*,
1111
};
1212
use bevy_image::BevyDefault as _;

crates/bevy_ecs/src/entity/clone_entities.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ mod tests {
844844
use super::ComponentCloneCtx;
845845
use crate::{
846846
component::{Component, ComponentCloneBehavior, ComponentDescriptor, StorageType},
847-
entity::{hash_map::EntityHashMap, Entity, EntityCloner, SourceComponent},
847+
entity::{Entity, EntityCloner, EntityHashMap, SourceComponent},
848848
prelude::{ChildOf, Children, Resource},
849849
reflect::{AppTypeRegistry, ReflectComponent, ReflectFromWorld},
850850
world::{FromWorld, World},

crates/bevy_ecs/src/entity/entity_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use core::{
1313
option, result,
1414
};
1515

16-
use super::{unique_slice::UniqueEntitySlice, Entity};
16+
use super::{Entity, UniqueEntitySlice};
1717

1818
use bevy_platform_support::sync::Arc;
1919

crates/bevy_ecs/src/entity/map_entities.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<A: smallvec::Array<Item = Entity>> MapEntities for SmallVec<A> {
108108
///
109109
/// ```
110110
/// # use bevy_ecs::entity::{Entity, EntityMapper};
111-
/// # use bevy_ecs::entity::hash_map::EntityHashMap;
111+
/// # use bevy_ecs::entity::EntityHashMap;
112112
/// #
113113
/// pub struct SimpleEntityMapper {
114114
/// map: EntityHashMap<Entity>,
@@ -281,7 +281,7 @@ impl<'m> SceneEntityMapper<'m> {
281281
#[cfg(test)]
282282
mod tests {
283283
use crate::{
284-
entity::{hash_map::EntityHashMap, Entity, EntityMapper, SceneEntityMapper},
284+
entity::{Entity, EntityHashMap, EntityMapper, SceneEntityMapper},
285285
world::World,
286286
};
287287

crates/bevy_ecs/src/entity/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,23 @@ pub use hash::*;
5454
pub mod hash_map;
5555
pub mod hash_set;
5656

57+
pub use hash_map::EntityHashMap;
58+
pub use hash_set::EntityHashSet;
59+
5760
pub mod index_map;
5861
pub mod index_set;
5962

63+
pub use index_map::EntityIndexMap;
64+
pub use index_set::EntityIndexSet;
65+
6066
pub mod unique_array;
6167
pub mod unique_slice;
6268
pub mod unique_vec;
6369

70+
pub use unique_array::UniqueEntityArray;
71+
pub use unique_slice::UniqueEntitySlice;
72+
pub use unique_vec::UniqueEntityVec;
73+
6474
use crate::{
6575
archetype::{ArchetypeId, ArchetypeRow},
6676
change_detection::MaybeLocation,

crates/bevy_ecs/src/entity/unique_slice.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ use alloc::{
2525
use bevy_platform_support::sync::Arc;
2626

2727
use super::{
28-
unique_array::UniqueEntityArray,
2928
unique_vec::{self, UniqueEntityVec},
3029
Entity, EntitySet, EntitySetIterator, FromEntitySetIterator, TrustedEntityBorrow,
31-
UniqueEntityIter,
30+
UniqueEntityArray, UniqueEntityIter,
3231
};
3332

3433
/// A slice that contains only unique entities.

crates/bevy_ecs/src/entity/unique_vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use alloc::{
2020
use bevy_platform_support::sync::Arc;
2121

2222
use super::{
23-
unique_array::UniqueEntityArray,
2423
unique_slice::{self, UniqueEntitySlice},
25-
Entity, EntitySet, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityIter,
24+
Entity, EntitySet, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityArray,
25+
UniqueEntityIter,
2626
};
2727

2828
/// A `Vec` that contains only unique entities.

crates/bevy_ecs/src/observer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
archetype::ArchetypeFlags,
1212
change_detection::MaybeLocation,
1313
component::ComponentId,
14-
entity::hash_map::EntityHashMap,
14+
entity::EntityHashMap,
1515
prelude::*,
1616
system::IntoObserverSystem,
1717
world::{DeferredWorld, *},

crates/bevy_ecs/src/query/par_iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
batching::BatchingStrategy,
33
component::Tick,
4-
entity::{unique_vec::UniqueEntityVec, EntityBorrow, TrustedEntityBorrow},
4+
entity::{EntityBorrow, TrustedEntityBorrow, UniqueEntityVec},
55
world::unsafe_world_cell::UnsafeWorldCell,
66
};
77

@@ -363,7 +363,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter, E: TrustedEntityBorrow + Sync>
363363
///
364364
/// ```
365365
/// use bevy_utils::Parallel;
366-
/// use crate::{bevy_ecs::{prelude::{Component, Res, Resource, Entity}, entity::unique_vec::UniqueEntityVec, system::Query}};
366+
/// use crate::{bevy_ecs::{prelude::{Component, Res, Resource, Entity}, entity::UniqueEntityVec, system::Query}};
367367
/// # use core::slice;
368368
/// # use crate::bevy_ecs::entity::UniqueEntityIter;
369369
/// # fn some_expensive_operation(_item: &T) -> usize {

0 commit comments

Comments
 (0)