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`
This commit is contained in:
parent
f68ed878e5
commit
32d53e7bd3
@ -13,7 +13,7 @@ use core::{
|
|||||||
option, result,
|
option, result,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{Entity, UniqueEntitySlice};
|
use super::{unique_slice::UniqueEntitySlice, Entity};
|
||||||
|
|
||||||
use bevy_platform_support::sync::Arc;
|
use bevy_platform_support::sync::Arc;
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
//! Contains the [`EntityIndexMap`] type, an [`IndexMap`] pre-configured to use [`EntityHash`] hashing.
|
||||||
|
//!
|
||||||
|
//! This module is a lightweight wrapper around `indexmap`'s [`IndexMap`] that is more performant for [`Entity`] keys.
|
||||||
|
|
||||||
use core::{
|
use core::{
|
||||||
fmt::{self, Debug, Formatter},
|
fmt::{self, Debug, Formatter},
|
||||||
hash::BuildHasher,
|
hash::BuildHasher,
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
//! Contains the [`EntityIndexSet`] type, a [`IndexSet`] pre-configured to use [`EntityHash`] hashing.
|
||||||
|
//!
|
||||||
|
//! This module is a lightweight wrapper around `indexmap`'ss [`IndexSet`] that is more performant for [`Entity`] keys.
|
||||||
|
|
||||||
use core::{
|
use core::{
|
||||||
fmt::{self, Debug, Formatter},
|
fmt::{self, Debug, Formatter},
|
||||||
hash::BuildHasher,
|
hash::BuildHasher,
|
||||||
|
@ -50,29 +50,18 @@ pub use entity_set::*;
|
|||||||
pub use map_entities::*;
|
pub use map_entities::*;
|
||||||
pub use visit_entities::*;
|
pub use visit_entities::*;
|
||||||
|
|
||||||
mod unique_vec;
|
|
||||||
|
|
||||||
pub use unique_vec::*;
|
|
||||||
|
|
||||||
mod hash;
|
mod hash;
|
||||||
pub use hash::*;
|
pub use hash::*;
|
||||||
|
|
||||||
pub mod hash_map;
|
pub mod hash_map;
|
||||||
pub mod hash_set;
|
pub mod hash_set;
|
||||||
|
|
||||||
mod index_map;
|
pub mod index_map;
|
||||||
mod index_set;
|
pub mod index_set;
|
||||||
|
|
||||||
pub use index_map::EntityIndexMap;
|
pub mod unique_array;
|
||||||
pub use index_set::EntityIndexSet;
|
pub mod unique_slice;
|
||||||
|
pub mod unique_vec;
|
||||||
mod unique_slice;
|
|
||||||
|
|
||||||
pub use unique_slice::*;
|
|
||||||
|
|
||||||
mod unique_array;
|
|
||||||
|
|
||||||
pub use unique_array::UniqueEntityArray;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
archetype::{ArchetypeId, ArchetypeRow},
|
archetype::{ArchetypeId, ArchetypeRow},
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//! A wrapper around entity arrays with a uniqueness invariant.
|
||||||
|
|
||||||
use core::{
|
use core::{
|
||||||
array,
|
array,
|
||||||
borrow::{Borrow, BorrowMut},
|
borrow::{Borrow, BorrowMut},
|
||||||
@ -18,7 +20,10 @@ use alloc::{
|
|||||||
|
|
||||||
use bevy_platform_support::sync::Arc;
|
use bevy_platform_support::sync::Arc;
|
||||||
|
|
||||||
use super::{unique_slice, TrustedEntityBorrow, UniqueEntityIter, UniqueEntitySlice};
|
use super::{
|
||||||
|
unique_slice::{self, UniqueEntitySlice},
|
||||||
|
TrustedEntityBorrow, UniqueEntityIter,
|
||||||
|
};
|
||||||
|
|
||||||
/// An array that contains only unique entities.
|
/// An array that contains only unique entities.
|
||||||
///
|
///
|
||||||
@ -522,6 +527,9 @@ impl<T: PartialEq<U>, U: TrustedEntityBorrow, const N: usize> PartialEq<UniqueEn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A by-value array iterator.
|
||||||
|
///
|
||||||
|
/// Equivalent to [`array::IntoIter`].
|
||||||
pub type IntoIter<T, const N: usize> = UniqueEntityIter<array::IntoIter<T, N>>;
|
pub type IntoIter<T, const N: usize> = UniqueEntityIter<array::IntoIter<T, N>>;
|
||||||
|
|
||||||
impl<T: TrustedEntityBorrow, const N: usize> UniqueEntityIter<array::IntoIter<T, N>> {
|
impl<T: TrustedEntityBorrow, const N: usize> UniqueEntityIter<array::IntoIter<T, N>> {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//! A wrapper around entity slices with a uniqueness invariant.
|
||||||
|
|
||||||
use core::{
|
use core::{
|
||||||
array::TryFromSliceError,
|
array::TryFromSliceError,
|
||||||
borrow::Borrow,
|
borrow::Borrow,
|
||||||
@ -23,8 +25,9 @@ use alloc::{
|
|||||||
use bevy_platform_support::sync::Arc;
|
use bevy_platform_support::sync::Arc;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
unique_vec, EntitySet, EntitySetIterator, FromEntitySetIterator, TrustedEntityBorrow,
|
unique_array::UniqueEntityArray,
|
||||||
UniqueEntityArray, UniqueEntityIter, UniqueEntityVec,
|
unique_vec::{self, UniqueEntityVec},
|
||||||
|
EntitySet, EntitySetIterator, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityIter,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A slice that contains only unique entities.
|
/// A slice that contains only unique entities.
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//! A wrapper around entity [`Vec`]s with a uniqueness invariant.
|
||||||
|
|
||||||
use core::{
|
use core::{
|
||||||
borrow::{Borrow, BorrowMut},
|
borrow::{Borrow, BorrowMut},
|
||||||
mem::MaybeUninit,
|
mem::MaybeUninit,
|
||||||
@ -18,8 +20,9 @@ use alloc::{
|
|||||||
use bevy_platform_support::sync::Arc;
|
use bevy_platform_support::sync::Arc;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
unique_slice, EntitySet, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityArray,
|
unique_array::UniqueEntityArray,
|
||||||
UniqueEntityIter, UniqueEntitySlice,
|
unique_slice::{self, UniqueEntitySlice},
|
||||||
|
EntitySet, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityIter,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A `Vec` that contains only unique entities.
|
/// A `Vec` that contains only unique entities.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
batching::BatchingStrategy,
|
batching::BatchingStrategy,
|
||||||
component::Tick,
|
component::Tick,
|
||||||
entity::{EntityBorrow, TrustedEntityBorrow, UniqueEntityVec},
|
entity::{unique_vec::UniqueEntityVec, EntityBorrow, TrustedEntityBorrow},
|
||||||
world::unsafe_world_cell::UnsafeWorldCell,
|
world::unsafe_world_cell::UnsafeWorldCell,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -363,7 +363,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter, E: TrustedEntityBorrow + Sync>
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use bevy_utils::Parallel;
|
/// use bevy_utils::Parallel;
|
||||||
/// use crate::{bevy_ecs::{prelude::{Component, Res, Resource, Entity}, entity::UniqueEntityVec, system::Query}};
|
/// use crate::{bevy_ecs::{prelude::{Component, Res, Resource, Entity}, entity::unique_vec::UniqueEntityVec, system::Query}};
|
||||||
/// # use core::slice;
|
/// # use core::slice;
|
||||||
/// # use crate::bevy_ecs::entity::UniqueEntityIter;
|
/// # use crate::bevy_ecs::entity::UniqueEntityIter;
|
||||||
/// # fn some_expensive_operation(_item: &T) -> usize {
|
/// # fn some_expensive_operation(_item: &T) -> usize {
|
||||||
|
@ -11,7 +11,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))]
|
#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))]
|
||||||
use crate::entity::{TrustedEntityBorrow, UniqueEntitySlice};
|
use crate::entity::{unique_slice::UniqueEntitySlice, TrustedEntityBorrow};
|
||||||
|
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use core::{fmt, ptr};
|
use core::{fmt, ptr};
|
||||||
|
Loading…
Reference in New Issue
Block a user