Skip to content

Commit 77cd9b3

Browse files
committed
Redoing some cleanup that got caught in the revert crossfire
1 parent 953dce3 commit 77cd9b3

2 files changed

Lines changed: 50 additions & 50 deletions

File tree

src/entity.rs

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use std::mem;
66
use std::num::NonZeroU32;
77

88
use crate::error::EcsError;
9-
use crate::index::{TrimmedIndex, MAX_DATA_INDEX};
10-
use crate::traits::{Archetype, ArchetypeCanResolve, EntityKey, EntityKeyTyped};
9+
use crate::index::{MAX_DATA_INDEX, TrimmedIndex};
10+
use crate::traits::*;
1111
use crate::version::{ArchetypeVersion, SlotVersion};
1212

1313
// NOTE: While this is extremely unlikely to change, if it does, the proc
@@ -488,6 +488,54 @@ impl EntityKey for EntityDirectAny {
488488
type DirectOutput = EntityDirectAny;
489489
}
490490

491+
impl<'a, A: Archetype + 'a, W: World> EntityKeySelectable<'a, W> for Entity<A>
492+
where
493+
W: WorldHas<A>,
494+
{
495+
type View = <A as Archetype>::View<'a>;
496+
type ViewMut = <A as Archetype>::ViewMut<'a>;
497+
type Borrow = <A as Archetype>::Borrow<'a>;
498+
499+
#[inline(always)]
500+
fn resolve_view(self, world: &'a mut W) -> Option<Self::View> {
501+
world.archetype_mut::<A>().view(self)
502+
}
503+
504+
#[inline(always)]
505+
fn resolve_view_mut(self, world: &'a mut W) -> Option<Self::ViewMut> {
506+
world.archetype_mut::<A>().view_mut(self)
507+
}
508+
509+
#[inline(always)]
510+
fn resolve_borrow(self, world: &'a W) -> Option<Self::Borrow> {
511+
world.archetype::<A>().borrow(self)
512+
}
513+
}
514+
515+
impl<'a, A: Archetype + 'a, W: World> EntityKeySelectable<'a, W> for EntityDirect<A>
516+
where
517+
W: WorldHas<A>,
518+
{
519+
type View = <A as Archetype>::View<'a>;
520+
type ViewMut = <A as Archetype>::ViewMut<'a>;
521+
type Borrow = <A as Archetype>::Borrow<'a>;
522+
523+
#[inline(always)]
524+
fn resolve_view(self, world: &'a mut W) -> Option<Self::View> {
525+
world.archetype_mut::<A>().view(self)
526+
}
527+
528+
#[inline(always)]
529+
fn resolve_view_mut(self, world: &'a mut W) -> Option<Self::ViewMut> {
530+
world.archetype_mut::<A>().view_mut(self)
531+
}
532+
533+
#[inline(always)]
534+
fn resolve_borrow(self, world: &'a W) -> Option<Self::Borrow> {
535+
world.archetype::<A>().borrow(self)
536+
}
537+
}
538+
491539
impl<'a, A: Archetype> From<&'a Entity<A>> for &'a EntityAny {
492540
#[inline(always)]
493541
fn from(value: &'a Entity<A>) -> Self {

src/traits.rs

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,51 +1097,3 @@ pub trait EntityKeySelectable<'a, W: World>: EntityKey {
10971097
#[doc(hidden)]
10981098
fn resolve_borrow(self, world: &'a W) -> Option<Self::Borrow>;
10991099
}
1100-
1101-
impl<'a, A: Archetype + 'a, W: World> EntityKeySelectable<'a, W> for Entity<A>
1102-
where
1103-
W: WorldHas<A>,
1104-
{
1105-
type View = <A as Archetype>::View<'a>;
1106-
type ViewMut = <A as Archetype>::ViewMut<'a>;
1107-
type Borrow = <A as Archetype>::Borrow<'a>;
1108-
1109-
#[inline(always)]
1110-
fn resolve_view(self, world: &'a mut W) -> Option<Self::View> {
1111-
world.archetype_mut::<A>().view(self)
1112-
}
1113-
1114-
#[inline(always)]
1115-
fn resolve_view_mut(self, world: &'a mut W) -> Option<Self::ViewMut> {
1116-
world.archetype_mut::<A>().view_mut(self)
1117-
}
1118-
1119-
#[inline(always)]
1120-
fn resolve_borrow(self, world: &'a W) -> Option<Self::Borrow> {
1121-
world.archetype::<A>().borrow(self)
1122-
}
1123-
}
1124-
1125-
impl<'a, A: Archetype + 'a, W: World> EntityKeySelectable<'a, W> for EntityDirect<A>
1126-
where
1127-
W: WorldHas<A>,
1128-
{
1129-
type View = <A as Archetype>::View<'a>;
1130-
type ViewMut = <A as Archetype>::ViewMut<'a>;
1131-
type Borrow = <A as Archetype>::Borrow<'a>;
1132-
1133-
#[inline(always)]
1134-
fn resolve_view(self, world: &'a mut W) -> Option<Self::View> {
1135-
world.archetype_mut::<A>().view(self)
1136-
}
1137-
1138-
#[inline(always)]
1139-
fn resolve_view_mut(self, world: &'a mut W) -> Option<Self::ViewMut> {
1140-
world.archetype_mut::<A>().view_mut(self)
1141-
}
1142-
1143-
#[inline(always)]
1144-
fn resolve_borrow(self, world: &'a W) -> Option<Self::Borrow> {
1145-
world.archetype::<A>().borrow(self)
1146-
}
1147-
}

0 commit comments

Comments
 (0)