Skip to content

Commit 32d53e7

Browse files
authored
make various entity wrapper type modules public (#18248)
# Objective Part of the #16547 series. The entity wrapper types often have some associated types an aliases with them that cannot be re-exported into an outer module together. Some helper types are best used with part of their path: `bevy::ecs::entity::index_set::Slice` as `index_set::Slice`. This has already been done for `entity::hash_set` and `entity::hash_map`. ## Solution Publicize the `index_set`, `index_map`, `unique_vec`, `unique_slice`, and `unique_array` modules. ## Migration Guide Any mention or import of types in the affected modules have to add the respective module name to the import path. F.e.: `bevy::ecs::entity::EntityIndexSet` -> `bevy::ecs::entity::index_set::EntityIndexSet`
1 parent f68ed87 commit 32d53e7

File tree

9 files changed

+36
-25
lines changed

9 files changed

+36
-25
lines changed

crates/bevy_ecs/src/entity/entity_set.rs

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

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

1818
use bevy_platform_support::sync::Arc;
1919

crates/bevy_ecs/src/entity/index_map.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Contains the [`EntityIndexMap`] type, an [`IndexMap`] pre-configured to use [`EntityHash`] hashing.
2+
//!
3+
//! This module is a lightweight wrapper around `indexmap`'s [`IndexMap`] that is more performant for [`Entity`] keys.
4+
15
use core::{
26
fmt::{self, Debug, Formatter},
37
hash::BuildHasher,

crates/bevy_ecs/src/entity/index_set.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Contains the [`EntityIndexSet`] type, a [`IndexSet`] pre-configured to use [`EntityHash`] hashing.
2+
//!
3+
//! This module is a lightweight wrapper around `indexmap`'ss [`IndexSet`] that is more performant for [`Entity`] keys.
4+
15
use core::{
26
fmt::{self, Debug, Formatter},
37
hash::BuildHasher,

crates/bevy_ecs/src/entity/mod.rs

+5-16
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,18 @@ pub use entity_set::*;
5050
pub use map_entities::*;
5151
pub use visit_entities::*;
5252

53-
mod unique_vec;
54-
55-
pub use unique_vec::*;
56-
5753
mod hash;
5854
pub use hash::*;
5955

6056
pub mod hash_map;
6157
pub mod hash_set;
6258

63-
mod index_map;
64-
mod index_set;
65-
66-
pub use index_map::EntityIndexMap;
67-
pub use index_set::EntityIndexSet;
68-
69-
mod unique_slice;
70-
71-
pub use unique_slice::*;
72-
73-
mod unique_array;
59+
pub mod index_map;
60+
pub mod index_set;
7461

75-
pub use unique_array::UniqueEntityArray;
62+
pub mod unique_array;
63+
pub mod unique_slice;
64+
pub mod unique_vec;
7665

7766
use crate::{
7867
archetype::{ArchetypeId, ArchetypeRow},

crates/bevy_ecs/src/entity/unique_array.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! A wrapper around entity arrays with a uniqueness invariant.
2+
13
use core::{
24
array,
35
borrow::{Borrow, BorrowMut},
@@ -18,7 +20,10 @@ use alloc::{
1820

1921
use bevy_platform_support::sync::Arc;
2022

21-
use super::{unique_slice, TrustedEntityBorrow, UniqueEntityIter, UniqueEntitySlice};
23+
use super::{
24+
unique_slice::{self, UniqueEntitySlice},
25+
TrustedEntityBorrow, UniqueEntityIter,
26+
};
2227

2328
/// An array that contains only unique entities.
2429
///
@@ -522,6 +527,9 @@ impl<T: PartialEq<U>, U: TrustedEntityBorrow, const N: usize> PartialEq<UniqueEn
522527
}
523528
}
524529

530+
/// A by-value array iterator.
531+
///
532+
/// Equivalent to [`array::IntoIter`].
525533
pub type IntoIter<T, const N: usize> = UniqueEntityIter<array::IntoIter<T, N>>;
526534

527535
impl<T: TrustedEntityBorrow, const N: usize> UniqueEntityIter<array::IntoIter<T, N>> {

crates/bevy_ecs/src/entity/unique_slice.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! A wrapper around entity slices with a uniqueness invariant.
2+
13
use core::{
24
array::TryFromSliceError,
35
borrow::Borrow,
@@ -23,8 +25,9 @@ use alloc::{
2325
use bevy_platform_support::sync::Arc;
2426

2527
use super::{
26-
unique_vec, EntitySet, EntitySetIterator, FromEntitySetIterator, TrustedEntityBorrow,
27-
UniqueEntityArray, UniqueEntityIter, UniqueEntityVec,
28+
unique_array::UniqueEntityArray,
29+
unique_vec::{self, UniqueEntityVec},
30+
EntitySet, EntitySetIterator, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityIter,
2831
};
2932

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

crates/bevy_ecs/src/entity/unique_vec.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! A wrapper around entity [`Vec`]s with a uniqueness invariant.
2+
13
use core::{
24
borrow::{Borrow, BorrowMut},
35
mem::MaybeUninit,
@@ -18,8 +20,9 @@ use alloc::{
1820
use bevy_platform_support::sync::Arc;
1921

2022
use super::{
21-
unique_slice, EntitySet, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityArray,
22-
UniqueEntityIter, UniqueEntitySlice,
23+
unique_array::UniqueEntityArray,
24+
unique_slice::{self, UniqueEntitySlice},
25+
EntitySet, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityIter,
2326
};
2427

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

crates/bevy_ecs/src/query/par_iter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
batching::BatchingStrategy,
33
component::Tick,
4-
entity::{EntityBorrow, TrustedEntityBorrow, UniqueEntityVec},
4+
entity::{unique_vec::UniqueEntityVec, EntityBorrow, TrustedEntityBorrow},
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::UniqueEntityVec, system::Query}};
366+
/// use crate::{bevy_ecs::{prelude::{Component, Res, Resource, Entity}, entity::unique_vec::UniqueEntityVec, system::Query}};
367367
/// # use core::slice;
368368
/// # use crate::bevy_ecs::entity::UniqueEntityIter;
369369
/// # fn some_expensive_operation(_item: &T) -> usize {

crates/bevy_ecs/src/query/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
};
1212

1313
#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))]
14-
use crate::entity::{TrustedEntityBorrow, UniqueEntitySlice};
14+
use crate::entity::{unique_slice::UniqueEntitySlice, TrustedEntityBorrow};
1515

1616
use alloc::vec::Vec;
1717
use core::{fmt, ptr};

0 commit comments

Comments
 (0)