add Entity default to the entity set wrappers (#18319)

# Objective

Installment of the #16547 series.

The vast majority of uses for these types will be the `Entity` case, so
it makes sense for it to be the default.

## Solution

`UniqueEntityVec`, `UniqueEntitySlice`, `UniqueEntityArray` and their
helper iterator aliases now have `Entity` as a default.

Unfortunately, this means the the `T` parameter for `UniqueEntityArray`
now has to be ordered after the `N` constant, which breaks the
consistency to `[T; N]`.
Same with about a dozen iterator aliases that take some `P`/`F`
predicate/function parameter.
This should however be an ergonomic improvement in most cases, so we'll
just have to live with this inconsistency.

## Migration Guide

Switch type parameter order for the relevant wrapper types/aliases.
This commit is contained in:
Vic 2025-03-15 02:51:39 +01:00 committed by GitHub
parent cb3e6a88dc
commit b462f47864
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 156 additions and 150 deletions

View File

@ -22,7 +22,7 @@ use bevy_platform_support::sync::Arc;
use super::{ use super::{
unique_slice::{self, UniqueEntitySlice}, unique_slice::{self, UniqueEntitySlice},
TrustedEntityBorrow, UniqueEntityIter, Entity, TrustedEntityBorrow, UniqueEntityIter,
}; };
/// An array that contains only unique entities. /// An array that contains only unique entities.
@ -30,9 +30,9 @@ use super::{
/// It can be obtained through certain methods on [`UniqueEntitySlice`], /// It can be obtained through certain methods on [`UniqueEntitySlice`],
/// and some [`TryFrom`] implementations. /// and some [`TryFrom`] implementations.
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct UniqueEntityArray<T: TrustedEntityBorrow, const N: usize>([T; N]); pub struct UniqueEntityArray<const N: usize, T: TrustedEntityBorrow = Entity>([T; N]);
impl<T: TrustedEntityBorrow, const N: usize> UniqueEntityArray<T, N> { impl<T: TrustedEntityBorrow, const N: usize> UniqueEntityArray<N, T> {
/// Constructs a `UniqueEntityArray` from a [`[T; N]`] unsafely. /// Constructs a `UniqueEntityArray` from a [`[T; N]`] unsafely.
/// ///
/// # Safety /// # Safety
@ -127,12 +127,12 @@ impl<T: TrustedEntityBorrow, const N: usize> UniqueEntityArray<T, N> {
/// size as `self`. /// size as `self`.
/// ///
/// Equivalent to [`[T; N]::as_ref`](array::each_ref). /// Equivalent to [`[T; N]::as_ref`](array::each_ref).
pub fn each_ref(&self) -> UniqueEntityArray<&T, N> { pub fn each_ref(&self) -> UniqueEntityArray<N, &T> {
UniqueEntityArray(self.0.each_ref()) UniqueEntityArray(self.0.each_ref())
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> Deref for UniqueEntityArray<T, N> { impl<T: TrustedEntityBorrow, const N: usize> Deref for UniqueEntityArray<N, T> {
type Target = UniqueEntitySlice<T>; type Target = UniqueEntitySlice<T>;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
@ -141,19 +141,19 @@ impl<T: TrustedEntityBorrow, const N: usize> Deref for UniqueEntityArray<T, N> {
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> DerefMut for UniqueEntityArray<T, N> { impl<T: TrustedEntityBorrow, const N: usize> DerefMut for UniqueEntityArray<N, T> {
fn deref_mut(&mut self) -> &mut Self::Target { fn deref_mut(&mut self) -> &mut Self::Target {
// SAFETY: All elements in the original array are unique. // SAFETY: All elements in the original array are unique.
unsafe { UniqueEntitySlice::from_slice_unchecked_mut(&mut self.0) } unsafe { UniqueEntitySlice::from_slice_unchecked_mut(&mut self.0) }
} }
} }
impl<T: TrustedEntityBorrow> Default for UniqueEntityArray<T, 0> { impl<T: TrustedEntityBorrow> Default for UniqueEntityArray<0, T> {
fn default() -> Self { fn default() -> Self {
Self(Default::default()) Self(Default::default())
} }
} }
impl<'a, T: TrustedEntityBorrow, const N: usize> IntoIterator for &'a UniqueEntityArray<T, N> { impl<'a, T: TrustedEntityBorrow, const N: usize> IntoIterator for &'a UniqueEntityArray<N, T> {
type Item = &'a T; type Item = &'a T;
type IntoIter = unique_slice::Iter<'a, T>; type IntoIter = unique_slice::Iter<'a, T>;
@ -164,10 +164,10 @@ impl<'a, T: TrustedEntityBorrow, const N: usize> IntoIterator for &'a UniqueEnti
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> IntoIterator for UniqueEntityArray<T, N> { impl<T: TrustedEntityBorrow, const N: usize> IntoIterator for UniqueEntityArray<N, T> {
type Item = T; type Item = T;
type IntoIter = IntoIter<T, N>; type IntoIter = IntoIter<N, T>;
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
// SAFETY: All elements in the original array are unique. // SAFETY: All elements in the original array are unique.
@ -176,7 +176,7 @@ impl<T: TrustedEntityBorrow, const N: usize> IntoIterator for UniqueEntityArray<
} }
impl<T: TrustedEntityBorrow, const N: usize> AsRef<UniqueEntitySlice<T>> impl<T: TrustedEntityBorrow, const N: usize> AsRef<UniqueEntitySlice<T>>
for UniqueEntityArray<T, N> for UniqueEntityArray<N, T>
{ {
fn as_ref(&self) -> &UniqueEntitySlice<T> { fn as_ref(&self) -> &UniqueEntitySlice<T> {
self self
@ -184,7 +184,7 @@ impl<T: TrustedEntityBorrow, const N: usize> AsRef<UniqueEntitySlice<T>>
} }
impl<T: TrustedEntityBorrow, const N: usize> AsMut<UniqueEntitySlice<T>> impl<T: TrustedEntityBorrow, const N: usize> AsMut<UniqueEntitySlice<T>>
for UniqueEntityArray<T, N> for UniqueEntityArray<N, T>
{ {
fn as_mut(&mut self) -> &mut UniqueEntitySlice<T> { fn as_mut(&mut self) -> &mut UniqueEntitySlice<T> {
self self
@ -192,7 +192,7 @@ impl<T: TrustedEntityBorrow, const N: usize> AsMut<UniqueEntitySlice<T>>
} }
impl<T: TrustedEntityBorrow, const N: usize> Borrow<UniqueEntitySlice<T>> impl<T: TrustedEntityBorrow, const N: usize> Borrow<UniqueEntitySlice<T>>
for UniqueEntityArray<T, N> for UniqueEntityArray<N, T>
{ {
fn borrow(&self) -> &UniqueEntitySlice<T> { fn borrow(&self) -> &UniqueEntitySlice<T> {
self self
@ -200,7 +200,7 @@ impl<T: TrustedEntityBorrow, const N: usize> Borrow<UniqueEntitySlice<T>>
} }
impl<T: TrustedEntityBorrow, const N: usize> BorrowMut<UniqueEntitySlice<T>> impl<T: TrustedEntityBorrow, const N: usize> BorrowMut<UniqueEntitySlice<T>>
for UniqueEntityArray<T, N> for UniqueEntityArray<N, T>
{ {
fn borrow_mut(&mut self) -> &mut UniqueEntitySlice<T> { fn borrow_mut(&mut self) -> &mut UniqueEntitySlice<T> {
self self
@ -208,7 +208,7 @@ impl<T: TrustedEntityBorrow, const N: usize> BorrowMut<UniqueEntitySlice<T>>
} }
impl<T: TrustedEntityBorrow, const N: usize> Index<(Bound<usize>, Bound<usize>)> impl<T: TrustedEntityBorrow, const N: usize> Index<(Bound<usize>, Bound<usize>)>
for UniqueEntityArray<T, N> for UniqueEntityArray<N, T>
{ {
type Output = UniqueEntitySlice<T>; type Output = UniqueEntitySlice<T>;
fn index(&self, key: (Bound<usize>, Bound<usize>)) -> &Self::Output { fn index(&self, key: (Bound<usize>, Bound<usize>)) -> &Self::Output {
@ -217,7 +217,7 @@ impl<T: TrustedEntityBorrow, const N: usize> Index<(Bound<usize>, Bound<usize>)>
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> Index<Range<usize>> for UniqueEntityArray<T, N> { impl<T: TrustedEntityBorrow, const N: usize> Index<Range<usize>> for UniqueEntityArray<N, T> {
type Output = UniqueEntitySlice<T>; type Output = UniqueEntitySlice<T>;
fn index(&self, key: Range<usize>) -> &Self::Output { fn index(&self, key: Range<usize>) -> &Self::Output {
// SAFETY: All elements in the original slice are unique. // SAFETY: All elements in the original slice are unique.
@ -225,7 +225,7 @@ impl<T: TrustedEntityBorrow, const N: usize> Index<Range<usize>> for UniqueEntit
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> Index<RangeFrom<usize>> for UniqueEntityArray<T, N> { impl<T: TrustedEntityBorrow, const N: usize> Index<RangeFrom<usize>> for UniqueEntityArray<N, T> {
type Output = UniqueEntitySlice<T>; type Output = UniqueEntitySlice<T>;
fn index(&self, key: RangeFrom<usize>) -> &Self::Output { fn index(&self, key: RangeFrom<usize>) -> &Self::Output {
// SAFETY: All elements in the original slice are unique. // SAFETY: All elements in the original slice are unique.
@ -233,7 +233,7 @@ impl<T: TrustedEntityBorrow, const N: usize> Index<RangeFrom<usize>> for UniqueE
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> Index<RangeFull> for UniqueEntityArray<T, N> { impl<T: TrustedEntityBorrow, const N: usize> Index<RangeFull> for UniqueEntityArray<N, T> {
type Output = UniqueEntitySlice<T>; type Output = UniqueEntitySlice<T>;
fn index(&self, key: RangeFull) -> &Self::Output { fn index(&self, key: RangeFull) -> &Self::Output {
// SAFETY: All elements in the original slice are unique. // SAFETY: All elements in the original slice are unique.
@ -242,7 +242,7 @@ impl<T: TrustedEntityBorrow, const N: usize> Index<RangeFull> for UniqueEntityAr
} }
impl<T: TrustedEntityBorrow, const N: usize> Index<RangeInclusive<usize>> impl<T: TrustedEntityBorrow, const N: usize> Index<RangeInclusive<usize>>
for UniqueEntityArray<T, N> for UniqueEntityArray<N, T>
{ {
type Output = UniqueEntitySlice<T>; type Output = UniqueEntitySlice<T>;
fn index(&self, key: RangeInclusive<usize>) -> &Self::Output { fn index(&self, key: RangeInclusive<usize>) -> &Self::Output {
@ -251,7 +251,7 @@ impl<T: TrustedEntityBorrow, const N: usize> Index<RangeInclusive<usize>>
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> Index<RangeTo<usize>> for UniqueEntityArray<T, N> { impl<T: TrustedEntityBorrow, const N: usize> Index<RangeTo<usize>> for UniqueEntityArray<N, T> {
type Output = UniqueEntitySlice<T>; type Output = UniqueEntitySlice<T>;
fn index(&self, key: RangeTo<usize>) -> &Self::Output { fn index(&self, key: RangeTo<usize>) -> &Self::Output {
// SAFETY: All elements in the original slice are unique. // SAFETY: All elements in the original slice are unique.
@ -260,7 +260,7 @@ impl<T: TrustedEntityBorrow, const N: usize> Index<RangeTo<usize>> for UniqueEnt
} }
impl<T: TrustedEntityBorrow, const N: usize> Index<RangeToInclusive<usize>> impl<T: TrustedEntityBorrow, const N: usize> Index<RangeToInclusive<usize>>
for UniqueEntityArray<T, N> for UniqueEntityArray<N, T>
{ {
type Output = UniqueEntitySlice<T>; type Output = UniqueEntitySlice<T>;
fn index(&self, key: RangeToInclusive<usize>) -> &Self::Output { fn index(&self, key: RangeToInclusive<usize>) -> &Self::Output {
@ -269,7 +269,7 @@ impl<T: TrustedEntityBorrow, const N: usize> Index<RangeToInclusive<usize>>
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> Index<usize> for UniqueEntityArray<T, N> { impl<T: TrustedEntityBorrow, const N: usize> Index<usize> for UniqueEntityArray<N, T> {
type Output = T; type Output = T;
fn index(&self, key: usize) -> &T { fn index(&self, key: usize) -> &T {
self.0.index(key) self.0.index(key)
@ -277,7 +277,7 @@ impl<T: TrustedEntityBorrow, const N: usize> Index<usize> for UniqueEntityArray<
} }
impl<T: TrustedEntityBorrow, const N: usize> IndexMut<(Bound<usize>, Bound<usize>)> impl<T: TrustedEntityBorrow, const N: usize> IndexMut<(Bound<usize>, Bound<usize>)>
for UniqueEntityArray<T, N> for UniqueEntityArray<N, T>
{ {
fn index_mut(&mut self, key: (Bound<usize>, Bound<usize>)) -> &mut Self::Output { fn index_mut(&mut self, key: (Bound<usize>, Bound<usize>)) -> &mut Self::Output {
// SAFETY: All elements in the original slice are unique. // SAFETY: All elements in the original slice are unique.
@ -285,7 +285,7 @@ impl<T: TrustedEntityBorrow, const N: usize> IndexMut<(Bound<usize>, Bound<usize
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> IndexMut<Range<usize>> for UniqueEntityArray<T, N> { impl<T: TrustedEntityBorrow, const N: usize> IndexMut<Range<usize>> for UniqueEntityArray<N, T> {
fn index_mut(&mut self, key: Range<usize>) -> &mut Self::Output { fn index_mut(&mut self, key: Range<usize>) -> &mut Self::Output {
// SAFETY: All elements in the original slice are unique. // SAFETY: All elements in the original slice are unique.
unsafe { UniqueEntitySlice::from_slice_unchecked_mut(self.0.index_mut(key)) } unsafe { UniqueEntitySlice::from_slice_unchecked_mut(self.0.index_mut(key)) }
@ -293,7 +293,7 @@ impl<T: TrustedEntityBorrow, const N: usize> IndexMut<Range<usize>> for UniqueEn
} }
impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeFrom<usize>> impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeFrom<usize>>
for UniqueEntityArray<T, N> for UniqueEntityArray<N, T>
{ {
fn index_mut(&mut self, key: RangeFrom<usize>) -> &mut Self::Output { fn index_mut(&mut self, key: RangeFrom<usize>) -> &mut Self::Output {
// SAFETY: All elements in the original slice are unique. // SAFETY: All elements in the original slice are unique.
@ -301,7 +301,7 @@ impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeFrom<usize>>
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeFull> for UniqueEntityArray<T, N> { impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeFull> for UniqueEntityArray<N, T> {
fn index_mut(&mut self, key: RangeFull) -> &mut Self::Output { fn index_mut(&mut self, key: RangeFull) -> &mut Self::Output {
// SAFETY: All elements in the original slice are unique. // SAFETY: All elements in the original slice are unique.
unsafe { UniqueEntitySlice::from_slice_unchecked_mut(self.0.index_mut(key)) } unsafe { UniqueEntitySlice::from_slice_unchecked_mut(self.0.index_mut(key)) }
@ -309,7 +309,7 @@ impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeFull> for UniqueEntit
} }
impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeInclusive<usize>> impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeInclusive<usize>>
for UniqueEntityArray<T, N> for UniqueEntityArray<N, T>
{ {
fn index_mut(&mut self, key: RangeInclusive<usize>) -> &mut Self::Output { fn index_mut(&mut self, key: RangeInclusive<usize>) -> &mut Self::Output {
// SAFETY: All elements in the original slice are unique. // SAFETY: All elements in the original slice are unique.
@ -317,7 +317,7 @@ impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeInclusive<usize>>
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeTo<usize>> for UniqueEntityArray<T, N> { impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeTo<usize>> for UniqueEntityArray<N, T> {
fn index_mut(&mut self, key: RangeTo<usize>) -> &mut Self::Output { fn index_mut(&mut self, key: RangeTo<usize>) -> &mut Self::Output {
// SAFETY: All elements in the original slice are unique. // SAFETY: All elements in the original slice are unique.
unsafe { UniqueEntitySlice::from_slice_unchecked_mut(self.0.index_mut(key)) } unsafe { UniqueEntitySlice::from_slice_unchecked_mut(self.0.index_mut(key)) }
@ -325,7 +325,7 @@ impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeTo<usize>> for Unique
} }
impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeToInclusive<usize>> impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeToInclusive<usize>>
for UniqueEntityArray<T, N> for UniqueEntityArray<N, T>
{ {
fn index_mut(&mut self, key: RangeToInclusive<usize>) -> &mut Self::Output { fn index_mut(&mut self, key: RangeToInclusive<usize>) -> &mut Self::Output {
// SAFETY: All elements in the original slice are unique. // SAFETY: All elements in the original slice are unique.
@ -333,148 +333,148 @@ impl<T: TrustedEntityBorrow, const N: usize> IndexMut<RangeToInclusive<usize>>
} }
} }
impl<T: TrustedEntityBorrow + Clone> From<&[T; 1]> for UniqueEntityArray<T, 1> { impl<T: TrustedEntityBorrow + Clone> From<&[T; 1]> for UniqueEntityArray<1, T> {
fn from(value: &[T; 1]) -> Self { fn from(value: &[T; 1]) -> Self {
Self(value.clone()) Self(value.clone())
} }
} }
impl<T: TrustedEntityBorrow + Clone> From<&[T; 0]> for UniqueEntityArray<T, 0> { impl<T: TrustedEntityBorrow + Clone> From<&[T; 0]> for UniqueEntityArray<0, T> {
fn from(value: &[T; 0]) -> Self { fn from(value: &[T; 0]) -> Self {
Self(value.clone()) Self(value.clone())
} }
} }
impl<T: TrustedEntityBorrow + Clone> From<&mut [T; 1]> for UniqueEntityArray<T, 1> { impl<T: TrustedEntityBorrow + Clone> From<&mut [T; 1]> for UniqueEntityArray<1, T> {
fn from(value: &mut [T; 1]) -> Self { fn from(value: &mut [T; 1]) -> Self {
Self(value.clone()) Self(value.clone())
} }
} }
impl<T: TrustedEntityBorrow + Clone> From<&mut [T; 0]> for UniqueEntityArray<T, 0> { impl<T: TrustedEntityBorrow + Clone> From<&mut [T; 0]> for UniqueEntityArray<0, T> {
fn from(value: &mut [T; 0]) -> Self { fn from(value: &mut [T; 0]) -> Self {
Self(value.clone()) Self(value.clone())
} }
} }
impl<T: TrustedEntityBorrow> From<[T; 1]> for UniqueEntityArray<T, 1> { impl<T: TrustedEntityBorrow> From<[T; 1]> for UniqueEntityArray<1, T> {
fn from(value: [T; 1]) -> Self { fn from(value: [T; 1]) -> Self {
Self(value) Self(value)
} }
} }
impl<T: TrustedEntityBorrow> From<[T; 0]> for UniqueEntityArray<T, 0> { impl<T: TrustedEntityBorrow> From<[T; 0]> for UniqueEntityArray<0, T> {
fn from(value: [T; 0]) -> Self { fn from(value: [T; 0]) -> Self {
Self(value) Self(value)
} }
} }
impl<T: TrustedEntityBorrow> From<UniqueEntityArray<T, 1>> for (T,) { impl<T: TrustedEntityBorrow> From<UniqueEntityArray<1, T>> for (T,) {
fn from(array: UniqueEntityArray<T, 1>) -> Self { fn from(array: UniqueEntityArray<1, T>) -> Self {
Self::from(array.into_inner()) Self::from(array.into_inner())
} }
} }
impl<T: TrustedEntityBorrow> From<UniqueEntityArray<T, 2>> for (T, T) { impl<T: TrustedEntityBorrow> From<UniqueEntityArray<2, T>> for (T, T) {
fn from(array: UniqueEntityArray<T, 2>) -> Self { fn from(array: UniqueEntityArray<2, T>) -> Self {
Self::from(array.into_inner()) Self::from(array.into_inner())
} }
} }
impl<T: TrustedEntityBorrow> From<UniqueEntityArray<T, 3>> for (T, T, T) { impl<T: TrustedEntityBorrow> From<UniqueEntityArray<3, T>> for (T, T, T) {
fn from(array: UniqueEntityArray<T, 3>) -> Self { fn from(array: UniqueEntityArray<3, T>) -> Self {
Self::from(array.into_inner()) Self::from(array.into_inner())
} }
} }
impl<T: TrustedEntityBorrow> From<UniqueEntityArray<T, 4>> for (T, T, T, T) { impl<T: TrustedEntityBorrow> From<UniqueEntityArray<4, T>> for (T, T, T, T) {
fn from(array: UniqueEntityArray<T, 4>) -> Self { fn from(array: UniqueEntityArray<4, T>) -> Self {
Self::from(array.into_inner()) Self::from(array.into_inner())
} }
} }
impl<T: TrustedEntityBorrow> From<UniqueEntityArray<T, 5>> for (T, T, T, T, T) { impl<T: TrustedEntityBorrow> From<UniqueEntityArray<5, T>> for (T, T, T, T, T) {
fn from(array: UniqueEntityArray<T, 5>) -> Self { fn from(array: UniqueEntityArray<5, T>) -> Self {
Self::from(array.into_inner()) Self::from(array.into_inner())
} }
} }
impl<T: TrustedEntityBorrow> From<UniqueEntityArray<T, 6>> for (T, T, T, T, T, T) { impl<T: TrustedEntityBorrow> From<UniqueEntityArray<6, T>> for (T, T, T, T, T, T) {
fn from(array: UniqueEntityArray<T, 6>) -> Self { fn from(array: UniqueEntityArray<6, T>) -> Self {
Self::from(array.into_inner()) Self::from(array.into_inner())
} }
} }
impl<T: TrustedEntityBorrow> From<UniqueEntityArray<T, 7>> for (T, T, T, T, T, T, T) { impl<T: TrustedEntityBorrow> From<UniqueEntityArray<7, T>> for (T, T, T, T, T, T, T) {
fn from(array: UniqueEntityArray<T, 7>) -> Self { fn from(array: UniqueEntityArray<7, T>) -> Self {
Self::from(array.into_inner()) Self::from(array.into_inner())
} }
} }
impl<T: TrustedEntityBorrow> From<UniqueEntityArray<T, 8>> for (T, T, T, T, T, T, T, T) { impl<T: TrustedEntityBorrow> From<UniqueEntityArray<8, T>> for (T, T, T, T, T, T, T, T) {
fn from(array: UniqueEntityArray<T, 8>) -> Self { fn from(array: UniqueEntityArray<8, T>) -> Self {
Self::from(array.into_inner()) Self::from(array.into_inner())
} }
} }
impl<T: TrustedEntityBorrow> From<UniqueEntityArray<T, 9>> for (T, T, T, T, T, T, T, T, T) { impl<T: TrustedEntityBorrow> From<UniqueEntityArray<9, T>> for (T, T, T, T, T, T, T, T, T) {
fn from(array: UniqueEntityArray<T, 9>) -> Self { fn from(array: UniqueEntityArray<9, T>) -> Self {
Self::from(array.into_inner()) Self::from(array.into_inner())
} }
} }
impl<T: TrustedEntityBorrow> From<UniqueEntityArray<T, 10>> for (T, T, T, T, T, T, T, T, T, T) { impl<T: TrustedEntityBorrow> From<UniqueEntityArray<10, T>> for (T, T, T, T, T, T, T, T, T, T) {
fn from(array: UniqueEntityArray<T, 10>) -> Self { fn from(array: UniqueEntityArray<10, T>) -> Self {
Self::from(array.into_inner()) Self::from(array.into_inner())
} }
} }
impl<T: TrustedEntityBorrow> From<UniqueEntityArray<T, 11>> for (T, T, T, T, T, T, T, T, T, T, T) { impl<T: TrustedEntityBorrow> From<UniqueEntityArray<11, T>> for (T, T, T, T, T, T, T, T, T, T, T) {
fn from(array: UniqueEntityArray<T, 11>) -> Self { fn from(array: UniqueEntityArray<11, T>) -> Self {
Self::from(array.into_inner()) Self::from(array.into_inner())
} }
} }
impl<T: TrustedEntityBorrow> From<UniqueEntityArray<T, 12>> impl<T: TrustedEntityBorrow> From<UniqueEntityArray<12, T>>
for (T, T, T, T, T, T, T, T, T, T, T, T) for (T, T, T, T, T, T, T, T, T, T, T, T)
{ {
fn from(array: UniqueEntityArray<T, 12>) -> Self { fn from(array: UniqueEntityArray<12, T>) -> Self {
Self::from(array.into_inner()) Self::from(array.into_inner())
} }
} }
impl<T: TrustedEntityBorrow + Ord, const N: usize> From<UniqueEntityArray<T, N>> for BTreeSet<T> { impl<T: TrustedEntityBorrow + Ord, const N: usize> From<UniqueEntityArray<N, T>> for BTreeSet<T> {
fn from(value: UniqueEntityArray<T, N>) -> Self { fn from(value: UniqueEntityArray<N, T>) -> Self {
BTreeSet::from(value.0) BTreeSet::from(value.0)
} }
} }
impl<T: TrustedEntityBorrow + Ord, const N: usize> From<UniqueEntityArray<T, N>> for BinaryHeap<T> { impl<T: TrustedEntityBorrow + Ord, const N: usize> From<UniqueEntityArray<N, T>> for BinaryHeap<T> {
fn from(value: UniqueEntityArray<T, N>) -> Self { fn from(value: UniqueEntityArray<N, T>) -> Self {
BinaryHeap::from(value.0) BinaryHeap::from(value.0)
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> From<UniqueEntityArray<T, N>> for LinkedList<T> { impl<T: TrustedEntityBorrow, const N: usize> From<UniqueEntityArray<N, T>> for LinkedList<T> {
fn from(value: UniqueEntityArray<T, N>) -> Self { fn from(value: UniqueEntityArray<N, T>) -> Self {
LinkedList::from(value.0) LinkedList::from(value.0)
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> From<UniqueEntityArray<T, N>> for Vec<T> { impl<T: TrustedEntityBorrow, const N: usize> From<UniqueEntityArray<N, T>> for Vec<T> {
fn from(value: UniqueEntityArray<T, N>) -> Self { fn from(value: UniqueEntityArray<N, T>) -> Self {
Vec::from(value.0) Vec::from(value.0)
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> From<UniqueEntityArray<T, N>> for VecDeque<T> { impl<T: TrustedEntityBorrow, const N: usize> From<UniqueEntityArray<N, T>> for VecDeque<T> {
fn from(value: UniqueEntityArray<T, N>) -> Self { fn from(value: UniqueEntityArray<N, T>) -> Self {
VecDeque::from(value.0) VecDeque::from(value.0)
} }
} }
impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize> impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize>
PartialEq<&UniqueEntitySlice<U>> for UniqueEntityArray<T, N> PartialEq<&UniqueEntitySlice<U>> for UniqueEntityArray<N, T>
{ {
fn eq(&self, other: &&UniqueEntitySlice<U>) -> bool { fn eq(&self, other: &&UniqueEntitySlice<U>) -> bool {
self.0.eq(&other.as_inner()) self.0.eq(&other.as_inner())
@ -482,47 +482,47 @@ impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usi
} }
impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize> impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize>
PartialEq<UniqueEntitySlice<U>> for UniqueEntityArray<T, N> PartialEq<UniqueEntitySlice<U>> for UniqueEntityArray<N, T>
{ {
fn eq(&self, other: &UniqueEntitySlice<U>) -> bool { fn eq(&self, other: &UniqueEntitySlice<U>) -> bool {
self.0.eq(other.as_inner()) self.0.eq(other.as_inner())
} }
} }
impl<T: PartialEq<U>, U: TrustedEntityBorrow, const N: usize> PartialEq<&UniqueEntityArray<U, N>> impl<T: PartialEq<U>, U: TrustedEntityBorrow, const N: usize> PartialEq<&UniqueEntityArray<N, U>>
for Vec<T> for Vec<T>
{ {
fn eq(&self, other: &&UniqueEntityArray<U, N>) -> bool { fn eq(&self, other: &&UniqueEntityArray<N, U>) -> bool {
self.eq(&other.0) self.eq(&other.0)
} }
} }
impl<T: PartialEq<U>, U: TrustedEntityBorrow, const N: usize> PartialEq<&UniqueEntityArray<U, N>> impl<T: PartialEq<U>, U: TrustedEntityBorrow, const N: usize> PartialEq<&UniqueEntityArray<N, U>>
for VecDeque<T> for VecDeque<T>
{ {
fn eq(&self, other: &&UniqueEntityArray<U, N>) -> bool { fn eq(&self, other: &&UniqueEntityArray<N, U>) -> bool {
self.eq(&other.0) self.eq(&other.0)
} }
} }
impl<T: PartialEq<U>, U: TrustedEntityBorrow, const N: usize> impl<T: PartialEq<U>, U: TrustedEntityBorrow, const N: usize>
PartialEq<&mut UniqueEntityArray<U, N>> for VecDeque<T> PartialEq<&mut UniqueEntityArray<N, U>> for VecDeque<T>
{ {
fn eq(&self, other: &&mut UniqueEntityArray<U, N>) -> bool { fn eq(&self, other: &&mut UniqueEntityArray<N, U>) -> bool {
self.eq(&other.0) self.eq(&other.0)
} }
} }
impl<T: PartialEq<U>, U: TrustedEntityBorrow, const N: usize> PartialEq<UniqueEntityArray<U, N>> impl<T: PartialEq<U>, U: TrustedEntityBorrow, const N: usize> PartialEq<UniqueEntityArray<N, U>>
for Vec<T> for Vec<T>
{ {
fn eq(&self, other: &UniqueEntityArray<U, N>) -> bool { fn eq(&self, other: &UniqueEntityArray<N, U>) -> bool {
self.eq(&other.0) self.eq(&other.0)
} }
} }
impl<T: PartialEq<U>, U: TrustedEntityBorrow, const N: usize> PartialEq<UniqueEntityArray<U, N>> impl<T: PartialEq<U>, U: TrustedEntityBorrow, const N: usize> PartialEq<UniqueEntityArray<N, U>>
for VecDeque<T> for VecDeque<T>
{ {
fn eq(&self, other: &UniqueEntityArray<U, N>) -> bool { fn eq(&self, other: &UniqueEntityArray<N, U>) -> bool {
self.eq(&other.0) self.eq(&other.0)
} }
} }
@ -530,7 +530,7 @@ impl<T: PartialEq<U>, U: TrustedEntityBorrow, const N: usize> PartialEq<UniqueEn
/// A by-value array iterator. /// A by-value array iterator.
/// ///
/// Equivalent to [`array::IntoIter`]. /// Equivalent to [`array::IntoIter`].
pub type IntoIter<T, const N: usize> = UniqueEntityIter<array::IntoIter<T, N>>; pub type IntoIter<const N: usize, T = Entity> = 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>> {
/// Returns an immutable slice of all elements that have not been yielded /// Returns an immutable slice of all elements that have not been yielded

View File

@ -27,7 +27,8 @@ use bevy_platform_support::sync::Arc;
use super::{ use super::{
unique_array::UniqueEntityArray, unique_array::UniqueEntityArray,
unique_vec::{self, UniqueEntityVec}, unique_vec::{self, UniqueEntityVec},
EntitySet, EntitySetIterator, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityIter, Entity, EntitySet, EntitySetIterator, FromEntitySetIterator, TrustedEntityBorrow,
UniqueEntityIter,
}; };
/// A slice that contains only unique entities. /// A slice that contains only unique entities.
@ -35,7 +36,7 @@ use super::{
/// It can be obtained by slicing [`UniqueEntityVec`]. /// It can be obtained by slicing [`UniqueEntityVec`].
#[repr(transparent)] #[repr(transparent)]
#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct UniqueEntitySlice<T: TrustedEntityBorrow>([T]); pub struct UniqueEntitySlice<T: TrustedEntityBorrow = Entity>([T]);
impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> { impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Constructs a `UniqueEntitySlice` from a [`&[T]`] unsafely. /// Constructs a `UniqueEntitySlice` from a [`&[T]`] unsafely.
@ -136,7 +137,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Returns an array reference to the first `N` items in the slice. /// Returns an array reference to the first `N` items in the slice.
/// ///
/// Equivalent to [`[T]::first_chunk`](slice::first_chunk). /// Equivalent to [`[T]::first_chunk`](slice::first_chunk).
pub const fn first_chunk<const N: usize>(&self) -> Option<&UniqueEntityArray<T, N>> { pub const fn first_chunk<const N: usize>(&self) -> Option<&UniqueEntityArray<N, T>> {
let Some(chunk) = self.0.first_chunk() else { let Some(chunk) = self.0.first_chunk() else {
return None; return None;
}; };
@ -149,7 +150,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Equivalent to [`[T]::split_first_chunk`](slice::split_first_chunk). /// Equivalent to [`[T]::split_first_chunk`](slice::split_first_chunk).
pub const fn split_first_chunk<const N: usize>( pub const fn split_first_chunk<const N: usize>(
&self, &self,
) -> Option<(&UniqueEntityArray<T, N>, &UniqueEntitySlice<T>)> { ) -> Option<(&UniqueEntityArray<N, T>, &UniqueEntitySlice<T>)> {
let Some((chunk, rest)) = self.0.split_first_chunk() else { let Some((chunk, rest)) = self.0.split_first_chunk() else {
return None; return None;
}; };
@ -167,7 +168,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Equivalent to [`[T]::split_last_chunk`](slice::split_last_chunk). /// Equivalent to [`[T]::split_last_chunk`](slice::split_last_chunk).
pub const fn split_last_chunk<const N: usize>( pub const fn split_last_chunk<const N: usize>(
&self, &self,
) -> Option<(&UniqueEntitySlice<T>, &UniqueEntityArray<T, N>)> { ) -> Option<(&UniqueEntitySlice<T>, &UniqueEntityArray<N, T>)> {
let Some((rest, chunk)) = self.0.split_last_chunk() else { let Some((rest, chunk)) = self.0.split_last_chunk() else {
return None; return None;
}; };
@ -183,7 +184,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Returns an array reference to the last `N` items in the slice. /// Returns an array reference to the last `N` items in the slice.
/// ///
/// Equivalent to [`[T]::last_chunk`](slice::last_chunk). /// Equivalent to [`[T]::last_chunk`](slice::last_chunk).
pub const fn last_chunk<const N: usize>(&self) -> Option<&UniqueEntityArray<T, N>> { pub const fn last_chunk<const N: usize>(&self) -> Option<&UniqueEntityArray<N, T>> {
let Some(chunk) = self.0.last_chunk() else { let Some(chunk) = self.0.last_chunk() else {
return None; return None;
}; };
@ -414,7 +415,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Equivalent to [`[T]::chunk_by`]. /// Equivalent to [`[T]::chunk_by`].
/// ///
/// [`[T]::chunk_by`]: `slice::chunk_by` /// [`[T]::chunk_by`]: `slice::chunk_by`
pub fn chunk_by<F>(&self, pred: F) -> ChunkBy<'_, T, F> pub fn chunk_by<F>(&self, pred: F) -> ChunkBy<'_, F, T>
where where
F: FnMut(&T, &T) -> bool, F: FnMut(&T, &T) -> bool,
{ {
@ -428,7 +429,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Equivalent to [`[T]::chunk_by_mut`]. /// Equivalent to [`[T]::chunk_by_mut`].
/// ///
/// [`[T]::chunk_by_mut`]: `slice::chunk_by_mut` /// [`[T]::chunk_by_mut`]: `slice::chunk_by_mut`
pub fn chunk_by_mut<F>(&mut self, pred: F) -> ChunkByMut<'_, T, F> pub fn chunk_by_mut<F>(&mut self, pred: F) -> ChunkByMut<'_, F, T>
where where
F: FnMut(&T, &T) -> bool, F: FnMut(&T, &T) -> bool,
{ {
@ -548,7 +549,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Equivalent to [`[T]::split`]. /// Equivalent to [`[T]::split`].
/// ///
/// [`[T]::split`]: `slice::split` /// [`[T]::split`]: `slice::split`
pub fn split<F>(&self, pred: F) -> Split<'_, T, F> pub fn split<F>(&self, pred: F) -> Split<'_, F, T>
where where
F: FnMut(&T) -> bool, F: FnMut(&T) -> bool,
{ {
@ -562,7 +563,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Equivalent to [`[T]::split_mut`]. /// Equivalent to [`[T]::split_mut`].
/// ///
/// [`[T]::split_mut`]: `slice::split_mut` /// [`[T]::split_mut`]: `slice::split_mut`
pub fn split_mut<F>(&mut self, pred: F) -> SplitMut<'_, T, F> pub fn split_mut<F>(&mut self, pred: F) -> SplitMut<'_, F, T>
where where
F: FnMut(&T) -> bool, F: FnMut(&T) -> bool,
{ {
@ -578,7 +579,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Equivalent to [`[T]::split_inclusive`]. /// Equivalent to [`[T]::split_inclusive`].
/// ///
/// [`[T]::split_inclusive`]: `slice::split_inclusive` /// [`[T]::split_inclusive`]: `slice::split_inclusive`
pub fn split_inclusive<F>(&self, pred: F) -> SplitInclusive<'_, T, F> pub fn split_inclusive<F>(&self, pred: F) -> SplitInclusive<'_, F, T>
where where
F: FnMut(&T) -> bool, F: FnMut(&T) -> bool,
{ {
@ -594,7 +595,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Equivalent to [`[T]::split_inclusive_mut`]. /// Equivalent to [`[T]::split_inclusive_mut`].
/// ///
/// [`[T]::split_inclusive_mut`]: `slice::split_inclusive_mut` /// [`[T]::split_inclusive_mut`]: `slice::split_inclusive_mut`
pub fn split_inclusive_mut<F>(&mut self, pred: F) -> SplitInclusiveMut<'_, T, F> pub fn split_inclusive_mut<F>(&mut self, pred: F) -> SplitInclusiveMut<'_, F, T>
where where
F: FnMut(&T) -> bool, F: FnMut(&T) -> bool,
{ {
@ -612,7 +613,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Equivalent to [`[T]::rsplit`]. /// Equivalent to [`[T]::rsplit`].
/// ///
/// [`[T]::rsplit`]: `slice::rsplit` /// [`[T]::rsplit`]: `slice::rsplit`
pub fn rsplit<F>(&self, pred: F) -> RSplit<'_, T, F> pub fn rsplit<F>(&self, pred: F) -> RSplit<'_, F, T>
where where
F: FnMut(&T) -> bool, F: FnMut(&T) -> bool,
{ {
@ -627,7 +628,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Equivalent to [`[T]::rsplit_mut`]. /// Equivalent to [`[T]::rsplit_mut`].
/// ///
/// [`[T]::rsplit_mut`]: `slice::rsplit_mut` /// [`[T]::rsplit_mut`]: `slice::rsplit_mut`
pub fn rsplit_mut<F>(&mut self, pred: F) -> RSplitMut<'_, T, F> pub fn rsplit_mut<F>(&mut self, pred: F) -> RSplitMut<'_, F, T>
where where
F: FnMut(&T) -> bool, F: FnMut(&T) -> bool,
{ {
@ -643,7 +644,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Equivalent to [`[T]::splitn`]. /// Equivalent to [`[T]::splitn`].
/// ///
/// [`[T]::splitn`]: `slice::splitn` /// [`[T]::splitn`]: `slice::splitn`
pub fn splitn<F>(&self, n: usize, pred: F) -> SplitN<'_, T, F> pub fn splitn<F>(&self, n: usize, pred: F) -> SplitN<'_, F, T>
where where
F: FnMut(&T) -> bool, F: FnMut(&T) -> bool,
{ {
@ -657,7 +658,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Equivalent to [`[T]::splitn_mut`]. /// Equivalent to [`[T]::splitn_mut`].
/// ///
/// [`[T]::splitn_mut`]: `slice::splitn_mut` /// [`[T]::splitn_mut`]: `slice::splitn_mut`
pub fn splitn_mut<F>(&mut self, n: usize, pred: F) -> SplitNMut<'_, T, F> pub fn splitn_mut<F>(&mut self, n: usize, pred: F) -> SplitNMut<'_, F, T>
where where
F: FnMut(&T) -> bool, F: FnMut(&T) -> bool,
{ {
@ -673,7 +674,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Equivalent to [`[T]::rsplitn`]. /// Equivalent to [`[T]::rsplitn`].
/// ///
/// [`[T]::rsplitn`]: `slice::rsplitn` /// [`[T]::rsplitn`]: `slice::rsplitn`
pub fn rsplitn<F>(&self, n: usize, pred: F) -> RSplitN<'_, T, F> pub fn rsplitn<F>(&self, n: usize, pred: F) -> RSplitN<'_, F, T>
where where
F: FnMut(&T) -> bool, F: FnMut(&T) -> bool,
{ {
@ -687,7 +688,7 @@ impl<T: TrustedEntityBorrow> UniqueEntitySlice<T> {
/// Equivalent to [`[T]::rsplitn_mut`]. /// Equivalent to [`[T]::rsplitn_mut`].
/// ///
/// [`[T]::rsplitn_mut`]: `slice::rsplitn_mut` /// [`[T]::rsplitn_mut`]: `slice::rsplitn_mut`
pub fn rsplitn_mut<F>(&mut self, n: usize, pred: F) -> RSplitNMut<'_, T, F> pub fn rsplitn_mut<F>(&mut self, n: usize, pred: F) -> RSplitNMut<'_, F, T>
where where
F: FnMut(&T) -> bool, F: FnMut(&T) -> bool,
{ {
@ -1012,10 +1013,10 @@ impl<'a, T: TrustedEntityBorrow + Clone> From<&'a UniqueEntitySlice<T>>
} }
} }
impl<T: TrustedEntityBorrow + Clone, const N: usize> From<UniqueEntityArray<T, N>> impl<T: TrustedEntityBorrow + Clone, const N: usize> From<UniqueEntityArray<N, T>>
for Box<UniqueEntitySlice<T>> for Box<UniqueEntitySlice<T>>
{ {
fn from(value: UniqueEntityArray<T, N>) -> Self { fn from(value: UniqueEntityArray<N, T>) -> Self {
// SAFETY: All elements in the original slice are unique. // SAFETY: All elements in the original slice are unique.
unsafe { UniqueEntitySlice::from_boxed_slice_unchecked(Box::new(value.into_inner())) } unsafe { UniqueEntitySlice::from_boxed_slice_unchecked(Box::new(value.into_inner())) }
} }
@ -1207,25 +1208,25 @@ impl<T: TrustedEntityBorrow + PartialEq<U>, U, const N: usize> PartialEq<[U; N]>
} }
impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize> impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize>
PartialEq<UniqueEntityArray<U, N>> for &UniqueEntitySlice<T> PartialEq<UniqueEntityArray<N, U>> for &UniqueEntitySlice<T>
{ {
fn eq(&self, other: &UniqueEntityArray<U, N>) -> bool { fn eq(&self, other: &UniqueEntityArray<N, U>) -> bool {
self.0.eq(&other.0) self.0.eq(&other.0)
} }
} }
impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize> impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize>
PartialEq<UniqueEntityArray<U, N>> for &mut UniqueEntitySlice<T> PartialEq<UniqueEntityArray<N, U>> for &mut UniqueEntitySlice<T>
{ {
fn eq(&self, other: &UniqueEntityArray<U, N>) -> bool { fn eq(&self, other: &UniqueEntityArray<N, U>) -> bool {
self.0.eq(&other.0) self.0.eq(&other.0)
} }
} }
impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize> impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize>
PartialEq<UniqueEntityArray<U, N>> for UniqueEntitySlice<T> PartialEq<UniqueEntityArray<N, U>> for UniqueEntitySlice<T>
{ {
fn eq(&self, other: &UniqueEntityArray<U, N>) -> bool { fn eq(&self, other: &UniqueEntityArray<N, U>) -> bool {
self.0.eq(&other.0) self.0.eq(&other.0)
} }
} }
@ -1258,7 +1259,7 @@ impl<T: TrustedEntityBorrow + Clone> ToOwned for UniqueEntitySlice<T> {
} }
impl<'a, T: TrustedEntityBorrow + Copy, const N: usize> TryFrom<&'a UniqueEntitySlice<T>> impl<'a, T: TrustedEntityBorrow + Copy, const N: usize> TryFrom<&'a UniqueEntitySlice<T>>
for &'a UniqueEntityArray<T, N> for &'a UniqueEntityArray<N, T>
{ {
type Error = TryFromSliceError; type Error = TryFromSliceError;
@ -1270,7 +1271,7 @@ impl<'a, T: TrustedEntityBorrow + Copy, const N: usize> TryFrom<&'a UniqueEntity
} }
impl<T: TrustedEntityBorrow + Copy, const N: usize> TryFrom<&UniqueEntitySlice<T>> impl<T: TrustedEntityBorrow + Copy, const N: usize> TryFrom<&UniqueEntitySlice<T>>
for UniqueEntityArray<T, N> for UniqueEntityArray<N, T>
{ {
type Error = TryFromSliceError; type Error = TryFromSliceError;
@ -1280,7 +1281,7 @@ impl<T: TrustedEntityBorrow + Copy, const N: usize> TryFrom<&UniqueEntitySlice<T
} }
impl<T: TrustedEntityBorrow + Copy, const N: usize> TryFrom<&mut UniqueEntitySlice<T>> impl<T: TrustedEntityBorrow + Copy, const N: usize> TryFrom<&mut UniqueEntitySlice<T>>
for UniqueEntityArray<T, N> for UniqueEntityArray<N, T>
{ {
type Error = TryFromSliceError; type Error = TryFromSliceError;
@ -1527,19 +1528,19 @@ impl<'a, T: TrustedEntityBorrow + 'a, I: Iterator<Item = &'a [T]> + AsRef<[&'a [
/// An iterator over overlapping subslices of length `size`. /// An iterator over overlapping subslices of length `size`.
/// ///
/// This struct is created by [`UniqueEntitySlice::windows`]. /// This struct is created by [`UniqueEntitySlice::windows`].
pub type Windows<'a, T> = UniqueEntitySliceIter<'a, T, slice::Windows<'a, T>>; pub type Windows<'a, T = Entity> = UniqueEntitySliceIter<'a, T, slice::Windows<'a, T>>;
/// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a /// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a
/// time), starting at the beginning of the slice. /// time), starting at the beginning of the slice.
/// ///
/// This struct is created by [`UniqueEntitySlice::chunks`]. /// This struct is created by [`UniqueEntitySlice::chunks`].
pub type Chunks<'a, T> = UniqueEntitySliceIter<'a, T, slice::Chunks<'a, T>>; pub type Chunks<'a, T = Entity> = UniqueEntitySliceIter<'a, T, slice::Chunks<'a, T>>;
/// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a /// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a
/// time), starting at the beginning of the slice. /// time), starting at the beginning of the slice.
/// ///
/// This struct is created by [`UniqueEntitySlice::chunks_exact`]. /// This struct is created by [`UniqueEntitySlice::chunks_exact`].
pub type ChunksExact<'a, T> = UniqueEntitySliceIter<'a, T, slice::ChunksExact<'a, T>>; pub type ChunksExact<'a, T = Entity> = UniqueEntitySliceIter<'a, T, slice::ChunksExact<'a, T>>;
impl<'a, T: TrustedEntityBorrow> UniqueEntitySliceIter<'a, T, slice::ChunksExact<'a, T>> { impl<'a, T: TrustedEntityBorrow> UniqueEntitySliceIter<'a, T, slice::ChunksExact<'a, T>> {
/// Returns the remainder of the original slice that is not going to be /// Returns the remainder of the original slice that is not going to be
@ -1556,13 +1557,13 @@ impl<'a, T: TrustedEntityBorrow> UniqueEntitySliceIter<'a, T, slice::ChunksExact
/// time), starting at the end of the slice. /// time), starting at the end of the slice.
/// ///
/// This struct is created by [`UniqueEntitySlice::rchunks`]. /// This struct is created by [`UniqueEntitySlice::rchunks`].
pub type RChunks<'a, T> = UniqueEntitySliceIter<'a, T, slice::RChunks<'a, T>>; pub type RChunks<'a, T = Entity> = UniqueEntitySliceIter<'a, T, slice::RChunks<'a, T>>;
/// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a /// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a
/// time), starting at the end of the slice. /// time), starting at the end of the slice.
/// ///
/// This struct is created by [`UniqueEntitySlice::rchunks_exact`]. /// This struct is created by [`UniqueEntitySlice::rchunks_exact`].
pub type RChunksExact<'a, T> = UniqueEntitySliceIter<'a, T, slice::RChunksExact<'a, T>>; pub type RChunksExact<'a, T = Entity> = UniqueEntitySliceIter<'a, T, slice::RChunksExact<'a, T>>;
impl<'a, T: TrustedEntityBorrow> UniqueEntitySliceIter<'a, T, slice::RChunksExact<'a, T>> { impl<'a, T: TrustedEntityBorrow> UniqueEntitySliceIter<'a, T, slice::RChunksExact<'a, T>> {
/// Returns the remainder of the original slice that is not going to be /// Returns the remainder of the original slice that is not going to be
@ -1578,38 +1579,39 @@ impl<'a, T: TrustedEntityBorrow> UniqueEntitySliceIter<'a, T, slice::RChunksExac
/// An iterator over slice in (non-overlapping) chunks separated by a predicate. /// An iterator over slice in (non-overlapping) chunks separated by a predicate.
/// ///
/// This struct is created by [`UniqueEntitySlice::chunk_by`]. /// This struct is created by [`UniqueEntitySlice::chunk_by`].
pub type ChunkBy<'a, T, P> = UniqueEntitySliceIter<'a, T, slice::ChunkBy<'a, T, P>>; pub type ChunkBy<'a, P, T = Entity> = UniqueEntitySliceIter<'a, T, slice::ChunkBy<'a, T, P>>;
/// An iterator over subslices separated by elements that match a predicate /// An iterator over subslices separated by elements that match a predicate
/// function. /// function.
/// ///
/// This struct is created by [`UniqueEntitySlice::split`]. /// This struct is created by [`UniqueEntitySlice::split`].
pub type Split<'a, T, P> = UniqueEntitySliceIter<'a, T, slice::Split<'a, T, P>>; pub type Split<'a, P, T = Entity> = UniqueEntitySliceIter<'a, T, slice::Split<'a, T, P>>;
/// An iterator over subslices separated by elements that match a predicate /// An iterator over subslices separated by elements that match a predicate
/// function. /// function.
/// ///
/// This struct is created by [`UniqueEntitySlice::split_inclusive`]. /// This struct is created by [`UniqueEntitySlice::split_inclusive`].
pub type SplitInclusive<'a, T, P> = UniqueEntitySliceIter<'a, T, slice::SplitInclusive<'a, T, P>>; pub type SplitInclusive<'a, P, T = Entity> =
UniqueEntitySliceIter<'a, T, slice::SplitInclusive<'a, T, P>>;
/// An iterator over subslices separated by elements that match a predicate /// An iterator over subslices separated by elements that match a predicate
/// function, starting from the end of the slice. /// function, starting from the end of the slice.
/// ///
/// This struct is created by [`UniqueEntitySlice::rsplit`]. /// This struct is created by [`UniqueEntitySlice::rsplit`].
pub type RSplit<'a, T, P> = UniqueEntitySliceIter<'a, T, slice::RSplit<'a, T, P>>; pub type RSplit<'a, P, T = Entity> = UniqueEntitySliceIter<'a, T, slice::RSplit<'a, T, P>>;
/// An iterator over subslices separated by elements that match a predicate /// An iterator over subslices separated by elements that match a predicate
/// function, limited to a given number of splits. /// function, limited to a given number of splits.
/// ///
/// This struct is created by [`UniqueEntitySlice::splitn`]. /// This struct is created by [`UniqueEntitySlice::splitn`].
pub type SplitN<'a, T, P> = UniqueEntitySliceIter<'a, T, slice::SplitN<'a, T, P>>; pub type SplitN<'a, P, T = Entity> = UniqueEntitySliceIter<'a, T, slice::SplitN<'a, T, P>>;
/// An iterator over subslices separated by elements that match a /// An iterator over subslices separated by elements that match a
/// predicate function, limited to a given number of splits, starting /// predicate function, limited to a given number of splits, starting
/// from the end of the slice. /// from the end of the slice.
/// ///
/// This struct is created by [`UniqueEntitySlice::rsplitn`]. /// This struct is created by [`UniqueEntitySlice::rsplitn`].
pub type RSplitN<'a, T, P> = UniqueEntitySliceIter<'a, T, slice::RSplitN<'a, T, P>>; pub type RSplitN<'a, P, T = Entity> = UniqueEntitySliceIter<'a, T, slice::RSplitN<'a, T, P>>;
/// An iterator that yields `&mut UniqueEntitySlice`. Note that an entity may appear /// An iterator that yields `&mut UniqueEntitySlice`. Note that an entity may appear
/// in multiple slices, depending on the wrapped iterator. /// in multiple slices, depending on the wrapped iterator.
@ -1713,13 +1715,14 @@ impl<'a, T: TrustedEntityBorrow + 'a, I: Iterator<Item = &'a mut [T]> + AsMut<[&
/// elements at a time), starting at the beginning of the slice. /// elements at a time), starting at the beginning of the slice.
/// ///
/// This struct is created by [`UniqueEntitySlice::chunks_mut`]. /// This struct is created by [`UniqueEntitySlice::chunks_mut`].
pub type ChunksMut<'a, T> = UniqueEntitySliceIterMut<'a, T, slice::ChunksMut<'a, T>>; pub type ChunksMut<'a, T = Entity> = UniqueEntitySliceIterMut<'a, T, slice::ChunksMut<'a, T>>;
/// An iterator over a slice in (non-overlapping) mutable chunks (`chunk_size` /// An iterator over a slice in (non-overlapping) mutable chunks (`chunk_size`
/// elements at a time), starting at the beginning of the slice. /// elements at a time), starting at the beginning of the slice.
/// ///
/// This struct is created by [`UniqueEntitySlice::chunks_exact_mut`]. /// This struct is created by [`UniqueEntitySlice::chunks_exact_mut`].
pub type ChunksExactMut<'a, T> = UniqueEntitySliceIterMut<'a, T, slice::ChunksExactMut<'a, T>>; pub type ChunksExactMut<'a, T = Entity> =
UniqueEntitySliceIterMut<'a, T, slice::ChunksExactMut<'a, T>>;
impl<'a, T: TrustedEntityBorrow> UniqueEntitySliceIterMut<'a, T, slice::ChunksExactMut<'a, T>> { impl<'a, T: TrustedEntityBorrow> UniqueEntitySliceIterMut<'a, T, slice::ChunksExactMut<'a, T>> {
/// Returns the remainder of the original slice that is not going to be /// Returns the remainder of the original slice that is not going to be
@ -1736,13 +1739,14 @@ impl<'a, T: TrustedEntityBorrow> UniqueEntitySliceIterMut<'a, T, slice::ChunksEx
/// elements at a time), starting at the end of the slice. /// elements at a time), starting at the end of the slice.
/// ///
/// This struct is created by [`UniqueEntitySlice::rchunks_mut`]. /// This struct is created by [`UniqueEntitySlice::rchunks_mut`].
pub type RChunksMut<'a, T> = UniqueEntitySliceIterMut<'a, T, slice::RChunksMut<'a, T>>; pub type RChunksMut<'a, T = Entity> = UniqueEntitySliceIterMut<'a, T, slice::RChunksMut<'a, T>>;
/// An iterator over a slice in (non-overlapping) mutable chunks (`chunk_size` /// An iterator over a slice in (non-overlapping) mutable chunks (`chunk_size`
/// elements at a time), starting at the end of the slice. /// elements at a time), starting at the end of the slice.
/// ///
/// This struct is created by [`UniqueEntitySlice::rchunks_exact_mut`]. /// This struct is created by [`UniqueEntitySlice::rchunks_exact_mut`].
pub type RChunksExactMut<'a, T> = UniqueEntitySliceIterMut<'a, T, slice::RChunksExactMut<'a, T>>; pub type RChunksExactMut<'a, T = Entity> =
UniqueEntitySliceIterMut<'a, T, slice::RChunksExactMut<'a, T>>;
impl<'a, T: TrustedEntityBorrow> UniqueEntitySliceIterMut<'a, T, slice::RChunksExactMut<'a, T>> { impl<'a, T: TrustedEntityBorrow> UniqueEntitySliceIterMut<'a, T, slice::RChunksExactMut<'a, T>> {
/// Returns the remainder of the original slice that is not going to be /// Returns the remainder of the original slice that is not going to be
@ -1759,37 +1763,39 @@ impl<'a, T: TrustedEntityBorrow> UniqueEntitySliceIterMut<'a, T, slice::RChunksE
/// by a predicate. /// by a predicate.
/// ///
/// This struct is created by [`UniqueEntitySlice::chunk_by_mut`]. /// This struct is created by [`UniqueEntitySlice::chunk_by_mut`].
pub type ChunkByMut<'a, T, P> = UniqueEntitySliceIterMut<'a, T, slice::ChunkByMut<'a, T, P>>; pub type ChunkByMut<'a, P, T = Entity> =
UniqueEntitySliceIterMut<'a, T, slice::ChunkByMut<'a, T, P>>;
/// An iterator over the mutable subslices of the vector which are separated /// An iterator over the mutable subslices of the vector which are separated
/// by elements that match `pred`. /// by elements that match `pred`.
/// ///
/// This struct is created by [`UniqueEntitySlice::split_mut`]. /// This struct is created by [`UniqueEntitySlice::split_mut`].
pub type SplitMut<'a, T, P> = UniqueEntitySliceIterMut<'a, T, slice::SplitMut<'a, T, P>>; pub type SplitMut<'a, P, T = Entity> = UniqueEntitySliceIterMut<'a, T, slice::SplitMut<'a, T, P>>;
/// An iterator over the mutable subslices of the vector which are separated /// An iterator over the mutable subslices of the vector which are separated
/// by elements that match `pred`. Unlike `SplitMut`, it contains the matched /// by elements that match `pred`. Unlike `SplitMut`, it contains the matched
/// parts in the ends of the subslices. /// parts in the ends of the subslices.
/// ///
/// This struct is created by [`UniqueEntitySlice::split_inclusive_mut`]. /// This struct is created by [`UniqueEntitySlice::split_inclusive_mut`].
pub type SplitInclusiveMut<'a, T, P> = pub type SplitInclusiveMut<'a, P, T = Entity> =
UniqueEntitySliceIterMut<'a, T, slice::SplitInclusiveMut<'a, T, P>>; UniqueEntitySliceIterMut<'a, T, slice::SplitInclusiveMut<'a, T, P>>;
/// An iterator over the subslices of the vector which are separated /// An iterator over the subslices of the vector which are separated
/// by elements that match `pred`, starting from the end of the slice. /// by elements that match `pred`, starting from the end of the slice.
/// ///
/// This struct is created by [`UniqueEntitySlice::rsplit_mut`]. /// This struct is created by [`UniqueEntitySlice::rsplit_mut`].
pub type RSplitMut<'a, T, P> = UniqueEntitySliceIterMut<'a, T, slice::RSplitMut<'a, T, P>>; pub type RSplitMut<'a, P, T = Entity> = UniqueEntitySliceIterMut<'a, T, slice::RSplitMut<'a, T, P>>;
/// An iterator over subslices separated by elements that match a predicate /// An iterator over subslices separated by elements that match a predicate
/// function, limited to a given number of splits. /// function, limited to a given number of splits.
/// ///
/// This struct is created by [`UniqueEntitySlice::splitn_mut`]. /// This struct is created by [`UniqueEntitySlice::splitn_mut`].
pub type SplitNMut<'a, T, P> = UniqueEntitySliceIterMut<'a, T, slice::SplitNMut<'a, T, P>>; pub type SplitNMut<'a, P, T = Entity> = UniqueEntitySliceIterMut<'a, T, slice::SplitNMut<'a, T, P>>;
/// An iterator over subslices separated by elements that match a /// An iterator over subslices separated by elements that match a
/// predicate function, limited to a given number of splits, starting /// predicate function, limited to a given number of splits, starting
/// from the end of the slice. /// from the end of the slice.
/// ///
/// This struct is created by [`UniqueEntitySlice::rsplitn_mut`]. /// This struct is created by [`UniqueEntitySlice::rsplitn_mut`].
pub type RSplitNMut<'a, T, P> = UniqueEntitySliceIterMut<'a, T, slice::RSplitNMut<'a, T, P>>; pub type RSplitNMut<'a, P, T = Entity> =
UniqueEntitySliceIterMut<'a, T, slice::RSplitNMut<'a, T, P>>;

View File

@ -22,7 +22,7 @@ use bevy_platform_support::sync::Arc;
use super::{ use super::{
unique_array::UniqueEntityArray, unique_array::UniqueEntityArray,
unique_slice::{self, UniqueEntitySlice}, unique_slice::{self, UniqueEntitySlice},
EntitySet, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityIter, Entity, EntitySet, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityIter,
}; };
/// A `Vec` that contains only unique entities. /// A `Vec` that contains only unique entities.
@ -36,7 +36,7 @@ use super::{
/// While this type can be constructed via `Iterator::collect`, doing so is inefficient, /// While this type can be constructed via `Iterator::collect`, doing so is inefficient,
/// and not recommended. /// and not recommended.
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct UniqueEntityVec<T: TrustedEntityBorrow>(Vec<T>); pub struct UniqueEntityVec<T: TrustedEntityBorrow = Entity>(Vec<T>);
impl<T: TrustedEntityBorrow> UniqueEntityVec<T> { impl<T: TrustedEntityBorrow> UniqueEntityVec<T> {
/// Constructs a new, empty `UniqueEntityVec<T>`. /// Constructs a new, empty `UniqueEntityVec<T>`.
@ -555,9 +555,9 @@ impl<T: TrustedEntityBorrow + PartialEq<U>, U, const N: usize> PartialEq<&[U; N]
} }
impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize> impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize>
PartialEq<&UniqueEntityArray<U, N>> for UniqueEntityVec<T> PartialEq<&UniqueEntityArray<N, U>> for UniqueEntityVec<T>
{ {
fn eq(&self, other: &&UniqueEntityArray<U, N>) -> bool { fn eq(&self, other: &&UniqueEntityArray<N, U>) -> bool {
self.0.eq(&other.as_inner()) self.0.eq(&other.as_inner())
} }
} }
@ -571,9 +571,9 @@ impl<T: TrustedEntityBorrow + PartialEq<U>, U, const N: usize> PartialEq<&mut [U
} }
impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize> impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize>
PartialEq<&mut UniqueEntityArray<U, N>> for UniqueEntityVec<T> PartialEq<&mut UniqueEntityArray<N, U>> for UniqueEntityVec<T>
{ {
fn eq(&self, other: &&mut UniqueEntityArray<U, N>) -> bool { fn eq(&self, other: &&mut UniqueEntityArray<N, U>) -> bool {
self.0.eq(other.as_inner()) self.0.eq(other.as_inner())
} }
} }
@ -601,9 +601,9 @@ impl<T: TrustedEntityBorrow + PartialEq<U>, U, const N: usize> PartialEq<[U; N]>
} }
impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize> impl<T: TrustedEntityBorrow + PartialEq<U>, U: TrustedEntityBorrow, const N: usize>
PartialEq<UniqueEntityArray<U, N>> for UniqueEntityVec<T> PartialEq<UniqueEntityArray<N, U>> for UniqueEntityVec<T>
{ {
fn eq(&self, other: &UniqueEntityArray<U, N>) -> bool { fn eq(&self, other: &UniqueEntityArray<N, U>) -> bool {
self.0.eq(other.as_inner()) self.0.eq(other.as_inner())
} }
} }
@ -711,24 +711,24 @@ impl<T: TrustedEntityBorrow> From<[T; 0]> for UniqueEntityVec<T> {
} }
} }
impl<T: TrustedEntityBorrow + Clone, const N: usize> From<&UniqueEntityArray<T, N>> impl<T: TrustedEntityBorrow + Clone, const N: usize> From<&UniqueEntityArray<N, T>>
for UniqueEntityVec<T> for UniqueEntityVec<T>
{ {
fn from(value: &UniqueEntityArray<T, N>) -> Self { fn from(value: &UniqueEntityArray<N, T>) -> Self {
Self(Vec::from(value.as_inner().clone())) Self(Vec::from(value.as_inner().clone()))
} }
} }
impl<T: TrustedEntityBorrow + Clone, const N: usize> From<&mut UniqueEntityArray<T, N>> impl<T: TrustedEntityBorrow + Clone, const N: usize> From<&mut UniqueEntityArray<N, T>>
for UniqueEntityVec<T> for UniqueEntityVec<T>
{ {
fn from(value: &mut UniqueEntityArray<T, N>) -> Self { fn from(value: &mut UniqueEntityArray<N, T>) -> Self {
Self(Vec::from(value.as_inner().clone())) Self(Vec::from(value.as_inner().clone()))
} }
} }
impl<T: TrustedEntityBorrow, const N: usize> From<UniqueEntityArray<T, N>> for UniqueEntityVec<T> { impl<T: TrustedEntityBorrow, const N: usize> From<UniqueEntityArray<N, T>> for UniqueEntityVec<T> {
fn from(value: UniqueEntityArray<T, N>) -> Self { fn from(value: UniqueEntityArray<N, T>) -> Self {
Self(Vec::from(value.into_inner())) Self(Vec::from(value.into_inner()))
} }
} }
@ -806,7 +806,7 @@ impl<T: TrustedEntityBorrow, const N: usize> TryFrom<UniqueEntityVec<T>> for Box
} }
impl<T: TrustedEntityBorrow, const N: usize> TryFrom<UniqueEntityVec<T>> impl<T: TrustedEntityBorrow, const N: usize> TryFrom<UniqueEntityVec<T>>
for Box<UniqueEntityArray<T, N>> for Box<UniqueEntityArray<N, T>>
{ {
type Error = UniqueEntityVec<T>; type Error = UniqueEntityVec<T>;
@ -828,7 +828,7 @@ impl<T: TrustedEntityBorrow, const N: usize> TryFrom<UniqueEntityVec<T>> for [T;
} }
impl<T: TrustedEntityBorrow, const N: usize> TryFrom<UniqueEntityVec<T>> impl<T: TrustedEntityBorrow, const N: usize> TryFrom<UniqueEntityVec<T>>
for UniqueEntityArray<T, N> for UniqueEntityArray<N, T>
{ {
type Error = UniqueEntityVec<T>; type Error = UniqueEntityVec<T>;
@ -1043,7 +1043,7 @@ impl<T: TrustedEntityBorrow> IndexMut<RangeToInclusive<usize>> for UniqueEntityV
/// ///
/// This `struct` is created by the [`IntoIterator::into_iter`] trait /// This `struct` is created by the [`IntoIterator::into_iter`] trait
/// method on [`UniqueEntityVec`]. /// method on [`UniqueEntityVec`].
pub type IntoIter<T> = UniqueEntityIter<vec::IntoIter<T>>; pub type IntoIter<T = Entity> = UniqueEntityIter<vec::IntoIter<T>>;
impl<T: TrustedEntityBorrow> UniqueEntityIter<vec::IntoIter<T>> { impl<T: TrustedEntityBorrow> UniqueEntityIter<vec::IntoIter<T>> {
/// Returns the remaining items of this iterator as a slice. /// Returns the remaining items of this iterator as a slice.
@ -1067,7 +1067,7 @@ impl<T: TrustedEntityBorrow> UniqueEntityIter<vec::IntoIter<T>> {
/// ///
/// This struct is created by [`UniqueEntityVec::drain`]. /// This struct is created by [`UniqueEntityVec::drain`].
/// See its documentation for more. /// See its documentation for more.
pub type Drain<'a, T> = UniqueEntityIter<vec::Drain<'a, T>>; pub type Drain<'a, T = Entity> = UniqueEntityIter<vec::Drain<'a, T>>;
impl<'a, T: TrustedEntityBorrow> UniqueEntityIter<vec::Drain<'a, T>> { impl<'a, T: TrustedEntityBorrow> UniqueEntityIter<vec::Drain<'a, T>> {
/// Returns the remaining items of this iterator as a slice. /// Returns the remaining items of this iterator as a slice.