diff --git a/CHANGELOG.md b/CHANGELOG.md index 684e9c86..10552da5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,37 @@ ## Unreleased +## 0.9.0 - 2023-04-22 +### Changed +- `resource::ContainsViews` now only requires a single generic parameter for indices. +- `World::view_resources()` now only requires a single generic parameter for indices. +- `registry::ContainsEntity` now only requires a single generic parameter for indices. +- `World::insert()` now only requires a single generic parameter for indices. +- `registry::ContainsEntities` now only requires a single generic parameter for indices. +- `World::extend()` now only requires a single generic parameter for indices. +- `World::insert()` no longer requires `E` to implement `Entity`. +- `World::extend()` no longer requires `E` to implement `Entities`. +- `World::query()` and `World::par_query()` both no longer require `V` and `F` to implement `Filter`. +- `registry::ContainsQuery` now only requires a single generic parameter for indices. +- `registry::ContainsParQuery` now only requires a single generic parameter for indices. +- `registry::ContainsViews` now only requires a single generic parameter for indices. +- `World::query()` now only requires a single parameter for query indices. +- `Entry::query()` now only requires a single parameter for query indices. +- `World::run_system()` now only requires a single parameter for query indices. +- `World::run_par_system()` now only requires a single parameter for query indices. +- `World::run_schedule()` now only requires a single parameter for query indices. +- `query::view::Disjoint` now only requires a single parameter for indices. +- `System::run()` now takes the results iterator as a generic parameter `I` to simplify the interface. +- `ParSystem::run()` now takes the results parallel iterator as a generic parameter `I` to simplify the interface. +- `System` and `ParSystem` both no longer require `Filter` and `Views` to implement `Filter`. +- `result::Iter` no longer requires `V` and `F` to implement `Filter`. +- `Entry::query()` no longer requires `V` and `F` to implement `Filter`. +- `system::schedule::Schedule` now only requires a single parameter for indices. +- `World::run_system()` now only requires a single parameter for schedule indices. +### Fixed +- `Schedule`s can now no longer access non-`Sync` components and resources. +- Multiple calls to `Entry::add()` or `Entry::remove()` that change the shape of the entity now no longer accesses the wrong internal entity row, preventing potential undefined behavior. + ## 0.8.2 - 2023-04-02 ### Fixed - `Entry::query()` now requires a less-strict lifetime. diff --git a/Cargo.toml b/Cargo.toml index b8f26587..129db147 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "brood" -version = "0.8.2" +version = "0.9.0" authors = ["Anders Evensen"] edition = "2021" rust-version = "1.65.0" @@ -27,7 +27,7 @@ serde = {version = "1.0.148", default-features = false, features = ["alloc"], op [dev-dependencies] claims = "0.7.1" rustversion = "1.0.9" -serde_assert = "0.2.0" +serde_assert = "0.4.0" serde_derive = "1.0.148" trybuild = "1.0.72" diff --git a/README.md b/README.md index 6b0d9d89..a3f7d3c3 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ Note that entities stored in `world` above can be made up of any subset of the ` To operate on the entities stored in a `World`, a `System` must be used. `System`s are defined to operate on any entities containing a specified set of components, reading and modifying those components. An example system could be defined and run as follows: ``` rust -use brood::{query::{filter, result, Views}, registry::ContainsQuery, system::System}; +use brood::{query::{filter, result, Views}, registry, system::System}; struct UpdatePosition; @@ -85,11 +85,12 @@ impl System for UpdatePosition { type ResourceViews: Views!(); type EntryViews: Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result, VI, P, I, Q>, Self::ResourceViews<'a>, Self::EntryViews<'a>, (EP, EI, EQ)>, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { for result!(position, velocity) in query_results.iter { position.x += velocity.x; @@ -160,7 +161,8 @@ Note that there are two modes for serialization, depending on whether the serial To parallelize system operations on entities (commonly referred to as inner-parallelism), a `ParSystem` can be used instead of a standard `System`. This will allow the `ParSystem`'s operations to be spread across multiple CPUs. For example, a `ParSystem` can be defined as follows: ``` rust -use brood::{entity, query::{filter, result, Views}, Registry, registry::ContainsParQuery, World, system::ParSystem}; +use brood::{entity, query::{filter, result, Views}, Registry, registry, World, system::ParSystem}; +use rayon::iter::ParallelIterator; struct Position { x: f32, @@ -195,11 +197,12 @@ impl ParSystem for UpdatePosition { type ResourceViews: Views!(); type EntryViews: Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result, VI, P, I, Q>, Self::ResourceViews<'a>, Self::EntryViews<'a>, (EP, EI, EQ)>, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { query_results.iter.for_each(|result!(position, velocity)| { position.x += velocity.x; @@ -219,7 +222,7 @@ Multiple `System`s and `ParSystem`s can be run in parallel as well by defining a Define and run a `Schedule` that contains multiple `System`s as follows: ``` rust -use brood::{entity, query::{filter, result, Views}, Registry, registry::ContainsQuery, World, system::{schedule, schedule::task, System}}; +use brood::{entity, query::{filter, result, Views}, Registry, registry, World, system::{schedule, schedule::task, System}}; struct Position { x: f32, @@ -256,11 +259,12 @@ impl System for UpdatePosition { type ResourceViews: Views!(); type EntryViews: Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result, VI, P, I, Q>, Self::ResourceViews<'a>, Self::EntryViews<'a>, (EP, EI, EQ)>, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { for result!(position, velocity) in query_results.iter { position.x += velocity.x; @@ -277,11 +281,12 @@ impl System for UpdateIsMoving { type ResourceViews: Views!(); type EntryViews: Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result, VI, P, I, Q>, Self::ResourceViews<'a>, Self::EntryViews<'a>, (EP, EI, EQ)>, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { for result!(velocity, is_moving) in query_results.iter { is_moving.0 = velocity.x != 0.0 || velocity.y != 0.0; diff --git a/src/archetype/impl_serde.rs b/src/archetype/impl_serde.rs index ffc3f4cd..19caee3e 100644 --- a/src/archetype/impl_serde.rs +++ b/src/archetype/impl_serde.rs @@ -948,7 +948,6 @@ mod tests { let mut deserializer = Deserializer::builder() .tokens(tokens) .is_human_readable(false) - .self_describing(false) .build(); assert_ok_eq!( Archetype::::deserialize(&mut deserializer), @@ -986,7 +985,6 @@ mod tests { Token::TupleEnd, ])) .is_human_readable(false) - .self_describing(false) .build(); assert_err_eq!( @@ -1062,7 +1060,6 @@ mod tests { Token::TupleEnd, ])) .is_human_readable(false) - .self_describing(false) .build(); assert_err_eq!( @@ -1089,7 +1086,6 @@ mod tests { Token::TupleEnd, ])) .is_human_readable(false) - .self_describing(false) .build(); assert_err_eq!( @@ -1163,7 +1159,6 @@ mod tests { Token::TupleEnd, ])) .is_human_readable(false) - .self_describing(false) .build(); assert_err_eq!( @@ -1189,7 +1184,6 @@ mod tests { Token::TupleEnd, ])) .is_human_readable(false) - .self_describing(false) .build(); assert_err_eq!( @@ -1211,7 +1205,6 @@ mod tests { Token::TupleEnd, ])) .is_human_readable(false) - .self_describing(false) .build(); assert_err_eq!( @@ -1235,7 +1228,6 @@ mod tests { Token::TupleEnd, ])) .is_human_readable(false) - .self_describing(false) .build(); assert_err_eq!( @@ -1320,10 +1312,7 @@ mod tests { Token::TupleEnd, ]) ); - let mut deserializer = Deserializer::builder() - .tokens(tokens) - .self_describing(false) - .build(); + let mut deserializer = Deserializer::builder().tokens(tokens).build(); assert_ok_eq!( Archetype::::deserialize(&mut deserializer), archetype @@ -1350,7 +1339,6 @@ mod tests { Token::TupleEnd, Token::TupleEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -1398,7 +1386,6 @@ mod tests { Token::TupleEnd, Token::TupleEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -1432,7 +1419,6 @@ mod tests { Token::TupleEnd, Token::TupleEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -1482,7 +1468,6 @@ mod tests { Token::TupleEnd, Token::TupleEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -1507,7 +1492,6 @@ mod tests { Token::Tuple { len: 0 }, Token::TupleEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -1528,7 +1512,6 @@ mod tests { Token::TupleEnd, Token::TupleEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -1551,7 +1534,6 @@ mod tests { Token::U64(3), Token::TupleEnd, ])) - .self_describing(false) .build(); assert_err_eq!( diff --git a/src/archetype/mod.rs b/src/archetype/mod.rs index 8390abc5..ad80e660 100644 --- a/src/archetype/mod.rs +++ b/src/archetype/mod.rs @@ -34,9 +34,9 @@ use crate::{ }, Entity, }, - query::view::{ - Views, - ViewsSealed, + query::{ + view, + view::ViewsSealed, }, registry, registry::{ @@ -238,18 +238,18 @@ where /// # Safety /// Each component viewed by `V` must also be identified by this archetype's `Identifier`. - pub(crate) unsafe fn view<'a, V, P, I, Q>( + pub(crate) unsafe fn view<'a, Views, Indices>( &mut self, - ) -> <<>::Viewable as ContainsViewsOuter< + ) -> <<>::Viewable as ContainsViewsOuter< 'a, - V, - P, - I, - Q, + Views, + >::Containments, + >::Indices, + >::ReshapeIndices, >>::Canonical as ViewsSealed<'a>>::Results where - V: Views<'a>, - R: ContainsViews<'a, V, P, I, Q>, + Views: view::Views<'a>, + R: ContainsViews<'a, Views, Indices>, { // SAFETY: `self.components` contains the raw parts for `Vec`s of size `self.length` // for each component `C` identified in `self.identifier` in the canonical order defined by @@ -258,7 +258,7 @@ where // `self.entity_identifiers` also contains the raw parts for a valid // `Vec` of size `self.length`. unsafe { - >::Viewable::view( + >::Viewable::view( &self.components, self.entity_identifiers, self.length, @@ -309,19 +309,19 @@ where /// Each component viewed by `V` must also be identified by this archetype's `Identifier`. /// /// The index `index` must be a valid index into this archetype. - pub(crate) unsafe fn view_row_unchecked<'a, V, P, I, Q>( + pub(crate) unsafe fn view_row_unchecked<'a, Views, Indices>( &mut self, index: usize, - ) -> <>::Viewable as ContainsViewsOuter< + ) -> <>::Viewable as ContainsViewsOuter< 'a, - V, - P, - I, - Q, + Views, + >::Containments, + >::Indices, + >::ReshapeIndices, >>::Canonical where - V: Views<'a>, - R: ContainsViews<'a, V, P, I, Q>, + Views: view::Views<'a>, + R: ContainsViews<'a, Views, Indices>, { // SAFETY: `self.components` contains the raw parts for `Vec`s of size `self.length` // for each component `C` identified in `self.identifier` in the canonical order defined by @@ -334,7 +334,7 @@ where // this archetype, and therefore within the bounds of each column and the entity // identifiers of this archetype. unsafe { - >::Viewable::view_one( + >::Viewable::view_one( index, &self.components, self.entity_identifiers, @@ -346,19 +346,13 @@ where /// # Safety /// The index `index` must be a valid index into this archetype. - pub(crate) unsafe fn view_row_maybe_uninit_unchecked<'a, V, P, I, Q>( + pub(crate) unsafe fn view_row_maybe_uninit_unchecked<'a, Views, Indices>( &mut self, index: usize, - ) -> <<>::Viewable as ContainsViewsOuter< - 'a, - V, - P, - I, - Q, - >>::Canonical as ViewsSealed<'a>>::MaybeUninit + ) -> Views::MaybeUninit where - V: Views<'a>, - R: ContainsViews<'a, V, P, I, Q>, + Views: view::Views<'a>, + R: ContainsViews<'a, Views, Indices>, { // SAFETY: `self.components` contains the raw parts for `Vec`s of size `self.length` // for each component `C` identified in `self.identifier` in the canonical order defined by @@ -371,7 +365,7 @@ where // this archetype, and therefore within the bounds of each column and the entity // identifiers of this archetype. unsafe { - >::Viewable::view_one_maybe_uninit( + >::Viewable::view_one_maybe_uninit( index, &self.components, self.entity_identifiers, diff --git a/src/archetypes/impl_serde.rs b/src/archetypes/impl_serde.rs index b7d93120..6f159e3f 100644 --- a/src/archetypes/impl_serde.rs +++ b/src/archetypes/impl_serde.rs @@ -166,10 +166,7 @@ mod tests { Tokens(vec![Token::Seq { len: Some(0) }, Token::SeqEnd]) ); let mut len = 0; - let mut deserializer = Deserializer::builder() - .tokens(tokens) - .self_describing(false) - .build(); + let mut deserializer = Deserializer::builder().tokens(tokens).build(); assert_ok_eq!( DeserializeArchetypes::::new(&mut len).deserialize(&mut deserializer), archetypes @@ -375,7 +372,6 @@ mod tests { let mut deserializer = Deserializer::builder() .tokens(tokens) .is_human_readable(false) - .self_describing(false) .build(); assert_ok_eq!( DeserializeArchetypes::::new(&mut len).deserialize(&mut deserializer), @@ -429,7 +425,6 @@ mod tests { Token::TupleEnd, ])) .is_human_readable(false) - .self_describing(false) .build(); let mut len = 0; diff --git a/src/component.rs b/src/component.rs index 933c30db..d1295da1 100644 --- a/src/component.rs +++ b/src/component.rs @@ -49,4 +49,4 @@ use core::any::Any; /// won't be able to implement this trait manually. pub trait Component: Any {} -impl Component for C where C: Any {} +impl self::Component for Component where Component: Any {} diff --git a/src/entities/get.rs b/src/entities/get.rs deleted file mode 100644 index 705a8435..00000000 --- a/src/entities/get.rs +++ /dev/null @@ -1,90 +0,0 @@ -//! Extracts a component list from a batch of entities. -//! -//! This is defined for every entity that contains a given component. If an entity does not contain -//! a component, calling `get()` for that component will fail to compile. - -use alloc::vec::Vec; - -/// Type marker for the location of a component. -/// -/// This does not actually have to be specified when calling `get()`. The compiler can infer its -/// location. -pub enum Index {} - -/// Extracts a list of components from entities. -/// -/// Removes the requested component, returning the remainder of the entities with the component -/// removed. -/// -/// If a component is not contained in the entity, attempting to `get()` it with this trait will -/// fail to compile. This is because it is defined recursively on either the component itself or -/// lists that have the component within them. -/// -/// This is generic over a component `T` and an index `I` (denoting the location of the component). -pub trait Get { - /// The entities returned after the component `T` is extracted. - type Remainder; - - /// Remove the component list `Vec` from the entity. - /// - /// Consumes the entities, returning the component and the entities with the component removed. - fn get(self) -> (Vec, Self::Remainder); -} - -impl Get for (Vec, E) { - type Remainder = E; - - fn get(self) -> (Vec, Self::Remainder) { - self - } -} - -impl Get for (Vec, E) -where - E: Get, -{ - type Remainder = (Vec, >::Remainder); - - fn get(self) -> (Vec, Self::Remainder) { - let (target, remainder) = self.1.get(); - (target, (self.0, remainder)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::entities; - use alloc::vec; - - #[derive(Clone, Debug, Eq, PartialEq)] - struct A; - #[derive(Clone, Debug, Eq, PartialEq)] - struct B; - #[derive(Clone, Debug, Eq, PartialEq)] - struct C; - - #[test] - fn get_a() { - assert_eq!( - entities!((A, B, C); 100).entities.get(), - (vec![A; 100], entities!((B, C); 100).entities) - ); - } - - #[test] - fn get_b() { - assert_eq!( - entities!((A, B, C); 100).entities.get(), - (vec![B; 100], entities!((A, C); 100).entities) - ); - } - - #[test] - fn get_c() { - assert_eq!( - entities!((A, B, C); 100).entities.get(), - (vec![C; 100], entities!((A, B); 100).entities) - ); - } -} diff --git a/src/entities/mod.rs b/src/entities/mod.rs index fb211868..098a9f59 100644 --- a/src/entities/mod.rs +++ b/src/entities/mod.rs @@ -39,14 +39,12 @@ //! [`Registry`]: crate::registry::Registry //! [`World`]: crate::world::World -mod get; mod sealed; -pub(crate) use get::Get; pub(crate) use sealed::Contains; use crate::{ - component::Component, + component, hlist::define_null, }; use alloc::vec::Vec; @@ -86,10 +84,10 @@ pub trait Entities: Sealed {} impl Entities for Null {} -impl Entities for (Vec, E) +impl self::Entities for (Vec, Entities) where - C: Component, - E: Entities, + Component: component::Component, + Entities: self::Entities, { } @@ -116,14 +114,14 @@ where /// [`Entities`]: crate::entities::Entities /// [`entities!`]: crate::entities! #[derive(Debug, Eq, PartialEq)] -pub struct Batch { - pub(crate) entities: E, +pub struct Batch { + pub(crate) entities: Entities, len: usize, } -impl Batch +impl Batch where - E: Entities, + Entities: self::Entities, { /// Creates a new `Batch`, wrapping the given [`Entities`] heterogeneous list. /// @@ -152,7 +150,7 @@ where /// /// # Panics /// Panics if the columns are not all the same length. - pub fn new(entities: E) -> Self { + pub fn new(entities: Entities) -> Self { assert!(entities.check_len()); // SAFETY: We just guaranteed the lengths of all columns are equal. unsafe { Self::new_unchecked(entities) } @@ -183,13 +181,15 @@ where /// ``` /// [`Entities`]: crate::entities::Entities /// [`entities!`]: crate::entities! - pub unsafe fn new_unchecked(entities: E) -> Self { + pub unsafe fn new_unchecked(entities: Entities) -> Self { Self { len: entities.component_len(), entities, } } +} +impl Batch { pub(crate) fn len(&self) -> usize { self.len } diff --git a/src/entity/allocator/impl_serde.rs b/src/entity/allocator/impl_serde.rs index e986884c..5172d1fa 100644 --- a/src/entity/allocator/impl_serde.rs +++ b/src/entity/allocator/impl_serde.rs @@ -367,10 +367,7 @@ mod tests { Token::StructEnd, ]) ); - let mut deserializer = Deserializer::builder() - .tokens(tokens) - .self_describing(false) - .build(); + let mut deserializer = Deserializer::builder().tokens(tokens).build(); assert_ok_eq!( DeserializeAllocator::new(&Archetypes::::new()) .deserialize(&mut deserializer), @@ -432,10 +429,7 @@ mod tests { Token::StructEnd, ]) ); - let mut deserializer = Deserializer::builder() - .tokens(tokens) - .self_describing(false) - .build(); + let mut deserializer = Deserializer::builder().tokens(tokens).build(); let archetypes = { let mut archetypes = Archetypes::::new(); let mut allocator = Allocator::new(); @@ -511,10 +505,7 @@ mod tests { Token::SeqEnd, ]) ); - let mut deserializer = Deserializer::builder() - .tokens(tokens) - .self_describing(false) - .build(); + let mut deserializer = Deserializer::builder().tokens(tokens).build(); let archetypes = { let mut archetypes = Archetypes::::new(); let mut allocator = Allocator::new(); @@ -557,7 +548,6 @@ mod tests { Token::SeqEnd, Token::StructEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -579,7 +569,6 @@ mod tests { Token::U64(0), Token::StructEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -605,7 +594,6 @@ mod tests { Token::Field("length"), Token::U64(0), ])) - .self_describing(false) .build(); assert_err_eq!( @@ -631,7 +619,6 @@ mod tests { Token::Field("free"), Token::Seq { len: Some(0) }, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -665,7 +652,6 @@ mod tests { Token::SeqEnd, Token::StructEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -708,7 +694,6 @@ mod tests { Token::SeqEnd, Token::StructEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -746,7 +731,6 @@ mod tests { Token::SeqEnd, Token::StructEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -792,7 +776,6 @@ mod tests { Token::SeqEnd, Token::StructEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -816,7 +799,6 @@ mod tests { Token::SeqEnd, Token::StructEnd, ])) - .self_describing(false) .build(); assert_err_eq!( diff --git a/src/entity/get.rs b/src/entity/get.rs deleted file mode 100644 index 5004ef99..00000000 --- a/src/entity/get.rs +++ /dev/null @@ -1,78 +0,0 @@ -//! Extracts a component from an entity. -//! -//! This is defined for every entity that contains a given component. If an entity does not contain -//! a component, calling `get()` for that component will fail to compile. - -/// Type marker for the location of a component. -/// -/// This does not actually have to be specified when calling `get()`. The compiler can infer its -/// location. -pub enum Index {} - -/// Extracts a component from an entity. -/// -/// Removes the requested component, returning the remainder of the entity with the component -/// removed. -/// -/// If a component is not contained in the entity, attempting to `get()` it with this trait will -/// fail to compile. This is because it is defined recursively on either the component itself or -/// lists that have the component within them. -/// -/// This is generic over a component `T` and an index `I` (denoting the location of the component). -pub trait Get { - /// The entity returned after the component `T` is extracted. - type Remainder; - - /// Remove the component `T` from the entity. - /// - /// Consumes the entity, returning the component and the entity with the component removed. - fn get(self) -> (T, Self::Remainder); -} - -impl Get for (T, E) { - type Remainder = E; - - fn get(self) -> (T, Self::Remainder) { - self - } -} - -impl Get for (C, E) -where - E: Get, -{ - type Remainder = (C, >::Remainder); - - fn get(self) -> (T, Self::Remainder) { - let (target, remainder) = self.1.get(); - (target, (self.0, remainder)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::entity; - - #[derive(Debug, Eq, PartialEq)] - struct A; - #[derive(Debug, Eq, PartialEq)] - struct B; - #[derive(Debug, Eq, PartialEq)] - struct C; - - #[test] - fn get_a() { - assert_eq!(entity!(A, B, C).get(), (A, entity!(B, C))); - } - - #[test] - fn get_b() { - assert_eq!(entity!(A, B, C).get(), (B, entity!(A, C))); - } - - #[test] - fn get_c() { - assert_eq!(entity!(A, B, C).get(), (C, entity!(A, B))); - } -} diff --git a/src/entity/identifier/impl_serde.rs b/src/entity/identifier/impl_serde.rs index 25beb3c4..c8914287 100644 --- a/src/entity/identifier/impl_serde.rs +++ b/src/entity/identifier/impl_serde.rs @@ -163,10 +163,7 @@ mod tests { Token::StructEnd, ]) ); - let mut deserializer = Deserializer::builder() - .tokens(tokens) - .self_describing(false) - .build(); + let mut deserializer = Deserializer::builder().tokens(tokens).build(); assert_ok_eq!(Identifier::deserialize(&mut deserializer), identifier); } @@ -182,7 +179,6 @@ mod tests { Token::U64(0), Token::StructEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -203,7 +199,6 @@ mod tests { Token::U64(0), Token::StructEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -224,7 +219,6 @@ mod tests { Token::U64(0), Token::Field("index"), ])) - .self_describing(false) .build(); assert_err_eq!( @@ -245,7 +239,6 @@ mod tests { Token::U64(0), Token::Field("generation"), ])) - .self_describing(false) .build(); assert_err_eq!( @@ -264,7 +257,6 @@ mod tests { }, Token::Field("unknown"), ])) - .self_describing(false) .build(); assert_err_eq!( @@ -289,10 +281,7 @@ mod tests { Token::SeqEnd, ]) ); - let mut deserializer = Deserializer::builder() - .tokens(tokens) - .self_describing(false) - .build(); + let mut deserializer = Deserializer::builder().tokens(tokens).build(); assert_ok_eq!(Identifier::deserialize(&mut deserializer), identifier); } @@ -300,7 +289,6 @@ mod tests { fn deserialize_from_seq_no_items() { let mut deserializer = Deserializer::builder() .tokens(Tokens(vec![Token::Seq { len: Some(0) }, Token::SeqEnd])) - .self_describing(false) .build(); assert_err_eq!( @@ -317,7 +305,6 @@ mod tests { Token::U64(1), Token::SeqEnd, ])) - .self_describing(false) .build(); assert_err_eq!( @@ -335,7 +322,6 @@ mod tests { Token::U64(2), Token::U64(3), ])) - .self_describing(false) .build(); assert_err_eq!( diff --git a/src/entity/mod.rs b/src/entity/mod.rs index c7fdd57d..b3f36a2b 100644 --- a/src/entity/mod.rs +++ b/src/entity/mod.rs @@ -35,6 +35,7 @@ //! world.insert(entity!()); //! ``` //! +//! [`Component`]: crate::component::Component //! [`Entity`]: crate::entity::Entity //! [`entity!`]: crate::entity! //! [`Identifier`]: crate::entity::Identifier @@ -43,17 +44,15 @@ pub(crate) mod allocator; -mod get; mod identifier; mod sealed; pub use identifier::Identifier; pub(crate) use allocator::Allocator; -pub(crate) use get::Get; use crate::{ - component::Component, + component, hlist::define_null, }; use sealed::Sealed; @@ -87,10 +86,10 @@ pub trait Entity: Sealed + 'static {} impl Entity for Null {} -impl Entity for (C, E) +impl self::Entity for (Component, Entity) where - C: Component, - E: Entity, + Component: component::Component, + Entity: self::Entity, { } diff --git a/src/hlist/get.rs b/src/hlist/get.rs new file mode 100644 index 00000000..b61362fe --- /dev/null +++ b/src/hlist/get.rs @@ -0,0 +1,70 @@ +//! Type extraction from heterogeneous lists. +//! +//! This logic is implemented generically for any 2-tuple heterogeneous list. Extracting a type +//! from a heterogeneous list is a fundamental operation, and it is used in many type definitions +//! throughout this library. + +/// Defines a type-level location within a heterogeneous list. +/// +/// The number of single-element tuples this type is nested within denotes the location of the +/// `Target` type. +pub enum Index {} + +/// Defines extraction from a heterogeneous list. +/// +/// This defines generic extraction for any 2-tuple heterogeneous list. The `Target` type is +/// extracted and the `Remainder` is the heterogeneous list without the `Target` type. +/// +/// `Index` can always be elided when used on a proper heterogeneous list (meaning that each type +/// within the list is unique), and can actually never be specified by an external user as `Index` +/// isn't exposed publicly. +pub trait Get { + /// The heterogeneous list with `Target` removed. + type Remainder; + + /// Extracts `Target` from the heterogeneous list, returning both the extracted value and the + /// heterogeneous list with the extracted value removed. + fn get(self) -> (Target, Self::Remainder); +} + +impl Get for (Head, Tail) { + type Remainder = Tail; + + fn get(self) -> (Head, Self::Remainder) { + self + } +} + +impl Get for (Head, Tail) +where + Tail: Get, +{ + type Remainder = (Head, Tail::Remainder); + + fn get(self) -> (Target, Self::Remainder) { + let (target, remainder) = self.1.get(); + (target, (self.0, remainder)) + } +} + +#[cfg(test)] +mod tests { + use super::Get; + + #[derive(Debug, PartialEq)] + struct A; + #[derive(Debug, PartialEq)] + struct B; + #[derive(Debug, PartialEq)] + struct Null; + + #[test] + fn get_head() { + assert_eq!(Get::::get((A, (B, Null))), (A, (B, Null))); + } + + #[test] + fn get_tail() { + assert_eq!(Get::::get((A, (B, Null))), (B, (A, Null))); + } +} diff --git a/src/hlist.rs b/src/hlist/mod.rs similarity index 84% rename from src/hlist.rs rename to src/hlist/mod.rs index 0e2ace8d..e7f6abb1 100644 --- a/src/hlist.rs +++ b/src/hlist/mod.rs @@ -1,3 +1,20 @@ +//! Generic 2-tuple heterogeneous list operations. +//! +//! A 2-tuple heterogeneous list is a list of nested 2-tuples containing unique types, with a +//! `Null` type denoting the end of the list. For example, `(A, (B, (C, Null)))` is a heterogeneous +//! list containing the unique types `A`, `B`, and `C`. 2-tuple heterogeneous lists are a +//! fundamental building block of this library, allowing type lists of arbitrary size to be used. +//! +//! This module provides generic operations on heterogeneous lists. Operations specific to certain +//! types of heterogeneous lists (for example, `View` lists or `Component` lists) are defined in +//! their specific modules. + +mod get; +mod reshape; + +pub(crate) use get::Get; +pub(crate) use reshape::Reshape; + macro_rules! define_null { () => { /// Represents the end of a heterogeneous list. @@ -76,6 +93,8 @@ macro_rules! define_null_uninstantiable { }; } +define_null_uninstantiable!(); + pub(crate) use define_null; pub(crate) use define_null_uninstantiable; diff --git a/src/hlist/reshape.rs b/src/hlist/reshape.rs new file mode 100644 index 00000000..84c4f147 --- /dev/null +++ b/src/hlist/reshape.rs @@ -0,0 +1,106 @@ +//! Reshaping of heterogeneous lists. +//! +//! This is a generic reshaping operation implemented for any 2-tuple heterogeneous list. A list +//! can be reshaped to another list containing the same elements in arbitrary order. +//! +//! Reshaping a heterogeneous list is a fundamental operation, and it is used in many type +//! definitions throughout this library. + +use crate::{ + hlist, + hlist::Get, +}; + +/// Reshapes one heterogeneous list into another heterogeneous list containing the same elements in +/// a different order. +/// +/// This is defined generically for any 2-tuple heterogeneous list. The `Null` value of the +/// heterogeneous list this operation is to be applied on should be provided as the `Null` generic +/// parameter. +/// +/// `Indices` can always be elided when used on a proper heterogeneous list (meaning each type +/// within the list is unique), and can never actually be specified by an external user as +/// [`get::Index`] is not exposed publicly. +/// +/// If the elements within `Self` do not match the elements within `Target` (in an arbitrary +/// order), including the `Null` element, then this trait will fail to be implemented, resulting in +/// a compilation error. +/// +/// [`get::Index`]: hlist::get::Index +pub trait Reshape { + /// Reshapes `self` into `Target`, consuming `self`. + fn reshape(self) -> Target; +} + +impl Reshape for Null { + fn reshape(self) -> Null { + self + } +} + +impl + Reshape<(TargetHead, TargetTail), (Index, Indices), Null> for List +where + List: Get, + List::Remainder: Reshape, +{ + fn reshape(self) -> (TargetHead, TargetTail) { + let (target, remainder) = self.get(); + (target, remainder.reshape()) + } +} + +#[cfg(test)] +mod tests { + use super::Reshape; + + #[derive(Debug, PartialEq)] + struct A; + #[derive(Debug, PartialEq)] + struct B; + #[derive(Debug, PartialEq)] + struct C; + #[derive(Debug, PartialEq)] + struct D; + #[derive(Debug, PartialEq)] + struct E; + #[derive(Debug, PartialEq)] + struct Null; + + #[test] + fn reshape_empty() { + assert_eq!(Reshape::::reshape(Null), Null); + } + + #[test] + fn reshape_single() { + assert_eq!(Reshape::<(A, Null), _, Null>::reshape((A, Null)), (A, Null)); + } + + #[test] + fn reshape_multiple_same_order() { + assert_eq!( + Reshape::<(A, (B, Null)), _, Null>::reshape((A, (B, Null))), + (A, (B, Null)) + ); + } + + #[test] + fn reshape_multiple_different_order() { + assert_eq!( + Reshape::<(B, (A, Null)), _, Null>::reshape((A, (B, Null))), + (B, (A, Null)) + ); + } + + #[test] + fn reshape_long() { + assert_eq!( + Reshape::<(B, (D, (E, (A, (C, Null))))), _, Null>::reshape(( + A, + (B, (C, (D, (E, Null)))) + )), + (B, (D, (E, (A, (C, Null))))) + ); + } +} diff --git a/src/lib.rs b/src/lib.rs index e5868047..5679ba1e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -100,6 +100,7 @@ #![no_std] #![cfg_attr(doc_cfg, feature(doc_cfg, decl_macro))] +#![cfg_attr(coverage_nightly, feature(no_coverage))] #![warn( clippy::expect_used, clippy::indexing_slicing, diff --git a/src/query/entries.rs b/src/query/entries.rs index 4d077a8e..17772412 100644 --- a/src/query/entries.rs +++ b/src/query/entries.rs @@ -12,10 +12,7 @@ use crate::{ query::{ filter::And, view, - view::{ - Reshape, - SubSet, - }, + view::SubSet, }, registry, registry::contains::views::{ @@ -50,11 +47,10 @@ where } } -impl<'a, 'b, Registry, Resources, Views, Containments, Indices, ReshapeIndices> - Entry<'a, 'b, Registry, Resources, Views, (Containments, Indices, ReshapeIndices)> +impl<'a, 'b, Registry, Resources, Views, Indices> Entry<'a, 'b, Registry, Resources, Views, Indices> where Views: view::Views<'a>, - Registry: registry::ContainsViews<'a, Views, Containments, Indices, ReshapeIndices>, + Registry: registry::ContainsViews<'a, Views, Indices>, { /// Query for components contained within this entity using the given `SubViews` and `Filter`. /// @@ -78,7 +74,7 @@ where And, >, { - let indices = <>::Viewable as ContainsViewsOuter<'a, Views, Containments, Indices, ReshapeIndices>>::indices(); + let indices = <>::Viewable as ContainsViewsOuter<'a, Views, >::Containments, >::Indices, >::ReshapeIndices>>::indices(); // SAFETY: The `indices` provided here are the valid indices into `Registry`, and therefore // into the `archetype::Identifier` used here. if unsafe { Views::filter(&indices, self.location.identifier) } { @@ -89,30 +85,15 @@ where // viewable by every possible `SubViews` (for example, in a `System` where the // `Registry` is generic). Therefore, we instead prove that the `Views` can be viewed // by the `SubViews`. - let super_views = <>::Viewable as ContainsViewsOuter< - Views, - Containments, - Indices, - ReshapeIndices - >>::Canonical::reshape_maybe_uninit( - // SAFETY: `self.location.index` is a valid - // index into this archetype, as guaranteed - // by the entity allocator. - unsafe { - (*self.entries.world).archetypes - .get_mut(self.location.identifier)? - .view_row_maybe_uninit_unchecked::< - Views, - Containments, - Indices, - ReshapeIndices - >(self.location.index) - }); + + // SAFETY: `self.location.index` is a valid index into this archetype, as guaranteed by + // the entity allocator. + let super_views = unsafe { + (*self.entries.world) + .archetypes + .get_mut(self.location.identifier)? + .view_row_maybe_uninit_unchecked::(self.location.index) + }; // SAFETY: `super_views` is viewed on the archetype identified by // `self.location.identifier`. The `indices` also correspond to the registry the diff --git a/src/query/filter/mod.rs b/src/query/filter/mod.rs index bddbfca5..04166f58 100644 --- a/src/query/filter/mod.rs +++ b/src/query/filter/mod.rs @@ -62,7 +62,7 @@ impl Filter for None {} /// Filter based on whether a [`Component`] is present in an entity. /// -/// This filters out any entities which do not have the `Component` `C`. No borrow of the value `C` +/// This filters out any entities which do not have the `Component`. No borrow of the `Component` /// from the entity is required. /// /// # Example' @@ -77,18 +77,15 @@ impl Filter for None {} /// ``` /// /// [`Component`]: crate::component::Component -pub struct Has -where - C: Component, -{ - component: PhantomData, +pub struct Has { + component: PhantomData, } -impl Filter for Has where C: Component {} +impl Filter for Has {} /// Filter using the logical inverse of another [`Filter`]. /// -/// This filters out any entities which would not have been filtered by the `Filter` `F`. +/// This filters out any entities which would not have been filtered by the `Filter`. /// /// # Example /// ``` rust @@ -105,16 +102,16 @@ impl Filter for Has where C: Component {} /// ``` /// /// [`Filter`]: crate::query::filter::Filter -pub struct Not { - filter: PhantomData, +pub struct Not { + filter: PhantomData, } -impl Filter for Not where F: Filter {} +impl self::Filter for Not where Filter: self::Filter {} /// Filter entities which are filtered by two [`Filter`]s. /// -/// This filter is a logical `and` between two `Filter`s `F1` and `F2`. Any entity filtered out by -/// either `Filter` will be filtered out by the `And` filter. +/// This filter is a logical `and` between two `Filter`s `FilterA` and `FilterB`. Any entity +/// filtered out by either `Filter` will be filtered out by the `And` filter. /// /// # Example /// ``` rust @@ -133,22 +130,22 @@ impl Filter for Not where F: Filter {} /// ``` /// /// [`Filter`]: crate::query::filter::Filter -pub struct And { - filter_1: PhantomData, - filter_2: PhantomData, +pub struct And { + filter_1: PhantomData, + filter_2: PhantomData, } -impl Filter for And +impl Filter for And where - F1: Filter, - F2: Filter, + FilterA: Filter, + FilterB: Filter, { } /// Filter entities which are filtered by one of two [`Filter`]s. /// -/// This filter is a logical `or` between two `Filter`s `F1` and `F2`. Any entity filtered out by -/// both `Filter`s will be filtered out by the `Or` filter. +/// This filter is a logical `or` between two `Filter`s `FilterA` and `FilterB`. Any entity +/// filtered out by both `Filter`s will be filtered out by the `Or` filter. /// /// # Example /// ``` rust @@ -167,15 +164,15 @@ where /// ``` /// /// [`Filter`]: crate::query::filter::Filter -pub struct Or { - filter_1: PhantomData, - filter_2: PhantomData, +pub struct Or { + filter_a: PhantomData, + filter_b: PhantomData, } -impl Filter for Or +impl Filter for Or where - F1: Filter, - F2: Filter, + FilterA: Filter, + FilterB: Filter, { } diff --git a/src/query/filter/sealed.rs b/src/query/filter/sealed.rs index bd69b222..272cad5a 100644 --- a/src/query/filter/sealed.rs +++ b/src/query/filter/sealed.rs @@ -18,7 +18,7 @@ pub trait Sealed {} impl Sealed for None {} -impl Sealed for Has where C: Component {} +impl Sealed for Has {} impl Sealed for Not where F: Filter {} diff --git a/src/query/result/archetype_claims.rs b/src/query/result/archetype_claims.rs index 4d6061da..3d182946 100644 --- a/src/query/result/archetype_claims.rs +++ b/src/query/result/archetype_claims.rs @@ -4,16 +4,13 @@ use crate::{ archetype, archetypes, query::{ - filter::{ - And, - Filter, - }, - view::Views, + filter::And, + view, }, + registry, registry::{ contains::filter::Sealed as ContainsFilterSealed, ContainsQuery, - Registry, }, }; use core::marker::PhantomData; @@ -22,52 +19,44 @@ use core::marker::PhantomData; /// /// This iterator returns key-value pairs of archetype identifiers and the list of claimed /// components for the given query on that archetype. -pub struct ArchetypeClaims<'a, R, F, FI, V, VI, P, I, Q> +pub struct ArchetypeClaims<'a, Registry, Filter, Views, Indices> where - R: Registry, + Registry: registry::Registry, { - archetypes_iter: archetypes::IterMut<'a, R>, + archetypes_iter: archetypes::IterMut<'a, Registry>, - filter: PhantomData, - filter_indices: PhantomData, - view: PhantomData, - view_filter_indices: PhantomData, - view_containments: PhantomData

, - view_indices: PhantomData, - reshape_indices: PhantomData, + filter: PhantomData, + view: PhantomData, + indices: PhantomData, } -impl<'a, R, F, FI, V, VI, P, I, Q> ArchetypeClaims<'a, R, F, FI, V, VI, P, I, Q> +impl<'a, Registry, Filter, Views, Indices> ArchetypeClaims<'a, Registry, Filter, Views, Indices> where - R: Registry, + Registry: registry::Registry, { /// Returns a new `ArchetypeClaims` iterator. /// /// # Safety /// The `archetype::IdentifierRef`s over which this iterator iterates must not outlive the /// `Archetypes` to which they belong. - pub(crate) unsafe fn new(archetypes_iter: archetypes::IterMut<'a, R>) -> Self { + pub(crate) unsafe fn new(archetypes_iter: archetypes::IterMut<'a, Registry>) -> Self { Self { archetypes_iter, filter: PhantomData, - filter_indices: PhantomData, view: PhantomData, - view_filter_indices: PhantomData, - view_containments: PhantomData, - view_indices: PhantomData, - reshape_indices: PhantomData, + indices: PhantomData, } } } -impl<'a, R, F, FI, V, VI, P, I, Q> Iterator for ArchetypeClaims<'a, R, F, FI, V, VI, P, I, Q> +impl<'a, Registry, Filter, Views, Indices> Iterator + for ArchetypeClaims<'a, Registry, Filter, Views, Indices> where - F: Filter, - V: Views<'a> + Filter, - R: ContainsQuery<'a, F, FI, V, VI, P, I, Q>, + Views: view::Views<'a>, + Registry: ContainsQuery<'a, Filter, Views, Indices>, { - type Item = (archetype::IdentifierRef, R::Claims); + type Item = (archetype::IdentifierRef, Registry::Claims); fn next(&mut self) -> Option { self.archetypes_iter @@ -76,9 +65,10 @@ where // identifier is generic over. Additionally, the identifier reference created here // will not outlive `archetype`. unsafe { - , And>>::filter( - archetype.identifier(), - ) + , + And, + >>::filter(archetype.identifier()) } }) .map(|archetype| { @@ -86,7 +76,7 @@ where // SAFETY: The `IdentifierRef` created here is guaranteed to outlive // `archetype`, so long as the safety contract at construction is upheld. unsafe { archetype.identifier() }, - R::claims(), + Registry::claims(), ) }) } diff --git a/src/query/result/get.rs b/src/query/result/get.rs deleted file mode 100644 index 3336f69f..00000000 --- a/src/query/result/get.rs +++ /dev/null @@ -1,27 +0,0 @@ -pub enum Index {} - -pub trait Get { - type Remainder; - - fn get(self) -> (T, Self::Remainder); -} - -impl Get for (T, R) { - type Remainder = R; - - fn get(self) -> (T, Self::Remainder) { - self - } -} - -impl Get for (U, R) -where - R: Get, -{ - type Remainder = (U, >::Remainder); - - fn get(self) -> (T, Self::Remainder) { - let (target, remainder) = self.1.get(); - (target, (self.0, remainder)) - } -} diff --git a/src/query/result/iter.rs b/src/query/result/iter.rs index d34f32db..06db7908 100644 --- a/src/query/result/iter.rs +++ b/src/query/result/iter.rs @@ -1,20 +1,15 @@ use crate::{ archetypes, + hlist::Reshape, query::{ - filter::{ - And, - Filter, - }, - result::{ - Reshape, - Results, - }, - view::Views, + filter::And, + result::Results, + view, }, + registry, registry::{ contains::filter::Sealed as ContainsFilterSealed, ContainsQuery, - Registry, }, }; use core::{ @@ -66,51 +61,42 @@ use core::{ /// [`result!`]: crate::query::result! /// [`Views`]: trait@crate::query::view::Views /// [`World`]: crate::world::World -pub struct Iter<'a, R, F, FI, V, VI, P, I, Q> +pub struct Iter<'a, Registry, Filter, Views, Indices> where - R: Registry, - V: Views<'a>, + Registry: registry::Registry, + Views: view::Views<'a>, { - archetypes_iter: archetypes::IterMut<'a, R>, + archetypes_iter: archetypes::IterMut<'a, Registry>, - current_results_iter: Option<::Iterator>, + current_results_iter: Option<::Iterator>, - filter: PhantomData, - filter_indices: PhantomData, - view_filter_indices: PhantomData, - view_containments: PhantomData

, - view_indices: PhantomData, - reshape_indices: PhantomData, + filter: PhantomData, + indices: PhantomData, } -impl<'a, R, F, FI, V, VI, P, I, Q> Iter<'a, R, F, FI, V, VI, P, I, Q> +impl<'a, Registry, Filter, Views, Indices> Iter<'a, Registry, Filter, Views, Indices> where - R: Registry, - V: Views<'a>, + Registry: registry::Registry, + Views: view::Views<'a>, { - pub(crate) fn new(archetypes_iter: archetypes::IterMut<'a, R>) -> Self { + pub(crate) fn new(archetypes_iter: archetypes::IterMut<'a, Registry>) -> Self { Self { archetypes_iter, current_results_iter: None, filter: PhantomData, - filter_indices: PhantomData, - view_filter_indices: PhantomData, - view_containments: PhantomData, - view_indices: PhantomData, - reshape_indices: PhantomData, + indices: PhantomData, } } } -impl<'a, R, F, FI, V, VI, P, I, Q> Iterator for Iter<'a, R, F, FI, V, VI, P, I, Q> +impl<'a, Registry, Filter, Views, Indices> Iterator for Iter<'a, Registry, Filter, Views, Indices> where - F: Filter, - V: Views<'a> + Filter, - R: ContainsQuery<'a, F, FI, V, VI, P, I, Q>, + Views: view::Views<'a>, + Registry: ContainsQuery<'a, Filter, Views, Indices>, { - type Item = V; + type Item = Views; #[inline] fn next(&mut self) -> Option { @@ -125,28 +111,35 @@ where // identifier is generic over. Additionally, the identifier reference created here // will not outlive `archetype`. unsafe { - , And>>::filter( - archetype.identifier(), - ) + , + And, + >>::filter(archetype.identifier()) } })?; self.current_results_iter = Some( // SAFETY: Each component viewed by `V` is guaranteed to be within the `archetype`, // since the archetype was not removed by the `find()` method above which filters // out archetypes that do not contain the viewed components. - unsafe { archetype.view::() } - .reshape() - .into_iterator(), + unsafe { + archetype.view::() + } + .reshape() + .into_iterator(), ); } } #[inline] fn size_hint(&self) -> (usize, Option) { - let (low, high) = self - .current_results_iter - .as_ref() - .map_or((0, Some(0)), ::Iterator::size_hint); + let (low, high) = self.current_results_iter.as_ref().map_or( + (0, Some(0)), + ::Iterator::size_hint, + ); match (self.archetypes_iter.size_hint(), high) { ((0, Some(0)), Some(_)) => (low, high), _ => (low, None), @@ -167,14 +160,23 @@ where // identifier is generic over. Additionally, the identifier reference created here will // not outlive `archetype`. if unsafe { - , And>>::filter(archetype.identifier()) + , + And, + >>::filter(archetype.identifier()) } { // SAFETY: Each component viewed by `V` is guaranteed to be within the `archetype` // since the `filter` function in the if-statement returned `true`. - unsafe { archetype.view::() } - .reshape() - .into_iterator() - .fold(acc, &mut fold) + unsafe { + archetype.view::() + } + .reshape() + .into_iterator() + .fold(acc, &mut fold) } else { acc } @@ -182,19 +184,20 @@ where } } -impl<'a, R, F, FI, V, VI, P, I, Q> FusedIterator for Iter<'a, R, F, FI, V, VI, P, I, Q> +impl<'a, Registry, Filter, Views, Indices> FusedIterator + for Iter<'a, Registry, Filter, Views, Indices> where - F: Filter, - V: Views<'a> + Filter, - R: ContainsQuery<'a, F, FI, V, VI, P, I, Q>, + Views: view::Views<'a>, + Registry: ContainsQuery<'a, Filter, Views, Indices>, { } // SAFETY: This type is safe to send between threads, as its mutable views are guaranteed to be // exclusive. -unsafe impl<'a, R, F, FI, V, VI, P, I, Q> Send for Iter<'a, R, F, FI, V, VI, P, I, Q> +unsafe impl<'a, Registry, Filter, Views, Indices> Send + for Iter<'a, Registry, Filter, Views, Indices> where - R: Registry, - V: Views<'a>, + Registry: registry::Registry, + Views: view::Views<'a>, { } diff --git a/src/query/result/mod.rs b/src/query/result/mod.rs index 06753176..38bd3c71 100644 --- a/src/query/result/mod.rs +++ b/src/query/result/mod.rs @@ -51,8 +51,6 @@ #[cfg(feature = "rayon")] pub(crate) mod archetype_claims; -pub(crate) mod get; -pub(crate) mod reshape; mod iter; #[cfg(feature = "rayon")] @@ -65,8 +63,6 @@ pub use par_iter::ParIter; #[cfg(feature = "rayon")] pub(crate) use archetype_claims::ArchetypeClaims; -pub(crate) use get::Get; -pub(crate) use reshape::Reshape; #[cfg(feature = "rayon")] pub(crate) use sealed::ParResults; pub(crate) use sealed::Results; diff --git a/src/query/result/par_iter.rs b/src/query/result/par_iter.rs index 29670d39..aa1c3106 100644 --- a/src/query/result/par_iter.rs +++ b/src/query/result/par_iter.rs @@ -1,21 +1,16 @@ use crate::{ archetype::Archetype, archetypes, + hlist::Reshape, query::{ filter::And, - result::{ - ParResults, - Reshape, - }, - view::{ - ParViews, - ParViewsSeal, - }, + result::ParResults, + view::ParViews, }, + registry, registry::{ contains::filter::Sealed as ContainsFilterSealed, ContainsParQuery, - Registry, }, }; use core::marker::PhantomData; @@ -78,118 +73,114 @@ use rayon::iter::{ /// [`result!`]: crate::query::result! /// [`World`]: crate::world::World #[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))] -pub struct ParIter<'a, R, F, FI, V, VI, P, I, Q> +pub struct ParIter<'a, Registry, Filter, Views, Indices> where - R: Registry, + Registry: registry::Registry, { - archetypes_iter: archetypes::ParIterMut<'a, R>, + archetypes_iter: archetypes::ParIterMut<'a, Registry>, - filter: PhantomData, - views: PhantomData, - filter_indices: PhantomData, - view_filter_indices: PhantomData, - view_containments: PhantomData

, - view_indices: PhantomData, - reshape_indices: PhantomData, + filter: PhantomData, + views: PhantomData, + indices: PhantomData, } -impl<'a, R, F, FI, V, VI, P, I, Q> ParIter<'a, R, F, FI, V, VI, P, I, Q> +impl<'a, Registry, Filter, Views, Indices> ParIter<'a, Registry, Filter, Views, Indices> where - R: Registry, + Registry: registry::Registry, { - pub(crate) fn new(archetypes_iter: archetypes::ParIterMut<'a, R>) -> Self { + pub(crate) fn new(archetypes_iter: archetypes::ParIterMut<'a, Registry>) -> Self { Self { archetypes_iter, filter: PhantomData, views: PhantomData, - filter_indices: PhantomData, - view_filter_indices: PhantomData, - view_containments: PhantomData, - view_indices: PhantomData, - reshape_indices: PhantomData, + indices: PhantomData, } } } // SAFETY: This type is safe to send between threads, as its mutable views are guaranteed to be // exclusive. -unsafe impl<'a, R, F, FI, V, VI, P, I, Q> Send for ParIter<'a, R, F, FI, V, VI, P, I, Q> where - R: Registry +unsafe impl<'a, Registry, Filter, Views, Indices> Send + for ParIter<'a, Registry, Filter, Views, Indices> +where + Registry: registry::Registry, { } // SAFETY: This type is safe to share between threads, as its mutable views are guaranteed to be // exclusive. -unsafe impl<'a, R, F, FI, V, VI, P, I, Q> Sync for ParIter<'a, R, F, FI, V, VI, P, I, Q> where - R: Registry +unsafe impl<'a, Registry, Filter, Views, Indices> Sync + for ParIter<'a, Registry, Filter, Views, Indices> +where + Registry: registry::Registry, { } -impl<'a, R, F, FI, V, VI, P, I, Q> ParallelIterator for ParIter<'a, R, F, FI, V, VI, P, I, Q> +impl<'a, Registry, Filter, Views, Indices> ParallelIterator + for ParIter<'a, Registry, Filter, Views, Indices> where - V: ParViews<'a>, - R: ContainsParQuery<'a, F, FI, V, VI, P, I, Q>, + Views: ParViews<'a>, + Registry: ContainsParQuery<'a, Filter, Views, Indices>, { - type Item = <>::ParResults as ParResults>::View; + type Item = <::Iterator as ParallelIterator>::Item; fn drive_unindexed(self, consumer: C) -> C::Result where C: UnindexedConsumer, { - let consumer = ResultsConsumer::<_, F, FI, V, VI, P, I, Q>::new(consumer); + let consumer = ResultsConsumer::<_, Filter, Views, Indices>::new(consumer); self.archetypes_iter.drive_unindexed(consumer) } } -struct ResultsConsumer { - base: C, +struct ResultsConsumer { + base: Consumer, - filter: PhantomData, - views: PhantomData, - filter_indices: PhantomData, - view_filter_indices: PhantomData, - view_containments: PhantomData

, - view_indices: PhantomData, - reshape_indices: PhantomData, + filter: PhantomData, + views: PhantomData, + indices: PhantomData, } -impl ResultsConsumer { - fn new(base: C) -> Self { +impl ResultsConsumer { + fn new(base: Consumer) -> Self { Self { base, filter: PhantomData, views: PhantomData, - filter_indices: PhantomData, - view_filter_indices: PhantomData, - view_containments: PhantomData, - view_indices: PhantomData, - reshape_indices: PhantomData, + indices: PhantomData, } } } // SAFETY: This type is safe to send between threads, as its mutable views are guaranteed to be // exclusive. -unsafe impl Send for ResultsConsumer {} +unsafe impl Send + for ResultsConsumer +{ +} // SAFETY: This type is safe to share between threads, as its mutable views are guaranteed to be // exclusive. -unsafe impl Sync for ResultsConsumer {} +unsafe impl Sync + for ResultsConsumer +{ +} -impl<'a, C, R, F, FI, V, VI, P, I, Q> Consumer<&'a mut Archetype> - for ResultsConsumer +impl<'a, _Consumer, Registry, Filter, Views, Indices> Consumer<&'a mut Archetype> + for ResultsConsumer<_Consumer, Filter, Views, Indices> where - C: UnindexedConsumer<<::Iterator as ParallelIterator>::Item>, - V: ParViews<'a>, - R: ContainsParQuery<'a, F, FI, V, VI, P, I, Q>, + _Consumer: + UnindexedConsumer<<::Iterator as ParallelIterator>::Item>, + Views: ParViews<'a>, + Registry: ContainsParQuery<'a, Filter, Views, Indices>, { - type Folder = ResultsFolder; - type Reducer = C::Reducer; - type Result = C::Result; + type Folder = ResultsFolder<_Consumer, _Consumer::Result, Filter, Views, Indices>; + type Reducer = _Consumer::Reducer; + type Result = _Consumer::Result; - fn split_at(self, index: usize) -> (Self, Self, C::Reducer) { + fn split_at(self, index: usize) -> (Self, Self, _Consumer::Reducer) { let (left, right, reducer) = self.base.split_at(index); ( ResultsConsumer::new(left), @@ -205,11 +196,7 @@ where filter: PhantomData, views: PhantomData, - filter_indices: PhantomData, - view_filter_indices: PhantomData, - view_containments: PhantomData, - view_indices: PhantomData, - reshape_indices: PhantomData, + indices: PhantomData, } } @@ -218,12 +205,13 @@ where } } -impl<'a, C, R, F, FI, V, VI, P, I, Q> UnindexedConsumer<&'a mut Archetype> - for ResultsConsumer +impl<'a, Consumer, Registry, Filter, Views, Indices> UnindexedConsumer<&'a mut Archetype> + for ResultsConsumer where - C: UnindexedConsumer<<::Iterator as ParallelIterator>::Item>, - V: ParViews<'a>, - R: ContainsParQuery<'a, F, FI, V, VI, P, I, Q>, + Consumer: + UnindexedConsumer<<::Iterator as ParallelIterator>::Item>, + Views: ParViews<'a>, + Registry: ContainsParQuery<'a, Filter, Views, Indices>, { fn split_off_left(&self) -> Self { ResultsConsumer::new(self.base.split_off_left()) @@ -234,40 +222,40 @@ where } } -struct ResultsFolder { - base: C, - previous: Option

, +struct ResultsFolder { + base: Consumer, + previous: Option, - filter: PhantomData, - views: PhantomData, - filter_indices: PhantomData, - view_filter_indices: PhantomData, - view_containments: PhantomData, - view_indices: PhantomData, - reshape_indices: PhantomData, + filter: PhantomData, + views: PhantomData, + indices: PhantomData, } -impl<'a, C, R, F, FI, V, VI, P, I, Q> Folder<&'a mut Archetype> - for ResultsFolder +impl<'a, Consumer, Registry, Filter, Views, Indices> Folder<&'a mut Archetype> + for ResultsFolder where - C: UnindexedConsumer<<::Iterator as ParallelIterator>::Item>, - R: ContainsParQuery<'a, F, FI, V, VI, P, I, Q>, - V: ParViews<'a>, + Consumer: + UnindexedConsumer<<::Iterator as ParallelIterator>::Item>, + Registry: ContainsParQuery<'a, Filter, Views, Indices>, + Views: ParViews<'a>, { - type Result = C::Result; + type Result = Consumer::Result; - fn consume(self, archetype: &'a mut Archetype) -> Self { + fn consume(self, archetype: &'a mut Archetype) -> Self { // SAFETY: The `R` on which `filter()` is called is the same `R` over which the identifier // is generic over. Additionally, the identifier reference created here will not outlive // `archetype`. if unsafe { - , And>>::filter(archetype.identifier()) + , + And, + >>::filter(archetype.identifier()) } { let consumer = self.base.split_off_left(); let result = // SAFETY: Each component viewed by `V` is guaranteed to be within the `archetype` // since the `filter` function in the if-statement returned `true`. - unsafe { archetype.par_view::() }.reshape().into_parallel_iterator().drive_unindexed(consumer); + unsafe { archetype.par_view::() }.reshape().into_parallel_iterator().drive_unindexed(consumer); let previous = match self.previous { None => Some(result), @@ -283,11 +271,7 @@ where filter: self.filter, views: self.views, - filter_indices: self.filter_indices, - view_filter_indices: self.view_filter_indices, - view_containments: self.view_containments, - view_indices: self.view_indices, - reshape_indices: self.reshape_indices, + indices: self.indices, } } else { self diff --git a/src/query/result/reshape.rs b/src/query/result/reshape.rs deleted file mode 100644 index 17576556..00000000 --- a/src/query/result/reshape.rs +++ /dev/null @@ -1,38 +0,0 @@ -use crate::{ - hlist::define_null_uninstantiable, - query::{ - result::Get, - view, - }, -}; -use core::iter; - -define_null_uninstantiable!(); - -pub trait Reshape { - fn reshape(self) -> R; -} - -impl Reshape>, Null> for iter::Take> { - fn reshape(self) -> iter::Take> { - self - } -} - -#[cfg(feature = "rayon")] -impl Reshape, Null> for rayon::iter::RepeatN { - fn reshape(self) -> rayon::iter::RepeatN { - self - } -} - -impl Reshape<(R, S), (I, IS)> for T -where - T: Get, - T::Remainder: Reshape, -{ - fn reshape(self) -> (R, S) { - let (target, remainder) = self.get(); - (target, remainder.reshape()) - } -} diff --git a/src/query/view/disjoint.rs b/src/query/view/disjoint.rs index 4d39967e..bb368ed5 100644 --- a/src/query/view/disjoint.rs +++ b/src/query/view/disjoint.rs @@ -7,9 +7,11 @@ use crate::{ entity, - hlist::define_null, + hlist::{ + define_null, + Get, + }, query::view, - registry, registry::ContainsViews, }; @@ -22,126 +24,40 @@ define_null!(); /// violating Rust's borrowing rules is what creates a conflict. /// /// [`Views`]: trait@crate::query::view::Views -pub trait Disjoint< - OtherViews, - Registry, - Containments, - Indices, - ReshapeIndices, - InverseIndices, - OppositeContainments, - OppositeIndices, - OppositeReshapeIndices, - OppositeInverseIndices, ->: - Sealed< - OtherViews, - Registry, - Containments, - Indices, - ReshapeIndices, - InverseIndices, - OppositeContainments, - OppositeIndices, - OppositeReshapeIndices, - OppositeInverseIndices, -> -{ -} +pub trait Disjoint: Sealed {} -impl< - Views, - OtherViews, - Registry, - Containments, - Indices, - ReshapeIndices, - InverseIndices, - OppositeContainments, - OppositeIndices, - OppositeReshapeIndices, - OppositeInverseIndices, - > - Disjoint< - OtherViews, - Registry, - Containments, - Indices, - ReshapeIndices, - InverseIndices, - OppositeContainments, - OppositeIndices, - OppositeReshapeIndices, - OppositeInverseIndices, - > for Views -where - Views: Sealed< - OtherViews, - Registry, - Containments, - Indices, - ReshapeIndices, - InverseIndices, - OppositeContainments, - OppositeIndices, - OppositeReshapeIndices, - OppositeInverseIndices, - >, +impl Disjoint for Views where + Views: Sealed { } -pub trait Sealed< - OtherViews, - Registry, - Containments, - Indices, - ReshapeIndices, - InverseIndices, - OppositeContainments, - OppositeIndices, - OppositeReshapeIndices, - OppositeInverseIndices, -> -{ -} +pub trait Sealed {} impl< 'a, Views, OtherViews, Registry, - Containments, Indices, - ReshapeIndices, InverseIndices, - OppositeContainments, OppositeIndices, - OppositeReshapeIndices, OppositeInverseIndices, > Sealed< OtherViews, Registry, - Containments, - Indices, - ReshapeIndices, - InverseIndices, - OppositeContainments, - OppositeIndices, - OppositeReshapeIndices, - OppositeInverseIndices, + ( + Indices, + InverseIndices, + OppositeIndices, + OppositeInverseIndices, + ), > for Views where OtherViews: view::Views<'a> + MutableInverse, - OtherViews::Result: ContainsViews<'a, Views, Containments, Indices, ReshapeIndices>, + OtherViews::Result: ContainsViews<'a, Views, Indices>, Views: view::Views<'a> + MutableInverse, - Views::Result: ContainsViews< - 'a, - OtherViews, - OppositeContainments, - OppositeIndices, - OppositeReshapeIndices, - >, + Views::Result: ContainsViews<'a, OtherViews, OppositeIndices>, { } @@ -178,25 +94,21 @@ where impl MutableInverse for (&mut Component, Views) where - Registry: registry::Get, - Views: MutableInverse<>::Remainder, Indices>, + Registry: Get, + Views: MutableInverse<>::Remainder, Indices>, { - type Result = >::Remainder, - Indices, - >>::Result; + type Result = + >::Remainder, Indices>>::Result; } impl MutableInverse for (Option<&mut Component>, Views) where - Registry: registry::Get, - Views: MutableInverse<>::Remainder, Indices>, + Registry: Get, + Views: MutableInverse<>::Remainder, Indices>, { - type Result = >::Remainder, - Indices, - >>::Result; + type Result = + >::Remainder, Indices>>::Result; } #[cfg(test)] @@ -208,32 +120,9 @@ mod tests { Registry, }; - fn is_disjoint< - Views, - OtherViews, - Registry, - Containments, - Indices, - ReshapeIndices, - InverseIndices, - OppositeContainments, - OppositeIndices, - OppositeReshapeIndices, - OppositeInverseIndices, - >() + fn is_disjoint() where - Views: Disjoint< - OtherViews, - Registry, - Containments, - Indices, - ReshapeIndices, - InverseIndices, - OppositeContainments, - OppositeIndices, - OppositeReshapeIndices, - OppositeInverseIndices, - >, + Views: Disjoint, { } @@ -246,22 +135,22 @@ mod tests { #[test] fn empty() { - is_disjoint::(); + is_disjoint::(); } #[test] fn empty_first_views() { - is_disjoint::), Registry, _, _, _, _, _, _, _, _>(); + is_disjoint::), Registry, _>(); } #[test] fn empty_second_views() { - is_disjoint::), Views!(), Registry, _, _, _, _, _, _, _, _>(); + is_disjoint::), Views!(), Registry, _>(); } #[test] fn shared_immutable_views() { - is_disjoint::(); + is_disjoint::(); } #[test] @@ -271,31 +160,12 @@ mod tests { Views!(Option<&A>, Option<&B>, Option<&C>), Registry, _, - _, - _, - _, - _, - _, - _, - _, >(); } #[test] fn disjoint_mutable_views() { - is_disjoint::< - Views!(&mut A, &mut C), - Views!(&mut B, entity::Identifier), - Registry, - _, - _, - _, - _, - _, - _, - _, - _, - >(); + is_disjoint::(); } #[test] @@ -305,30 +175,11 @@ mod tests { Views!(Option<&mut B>, entity::Identifier), Registry, _, - _, - _, - _, - _, - _, - _, - _, >(); } #[test] fn entity_identifier() { - is_disjoint::< - Views!(entity::Identifier), - Views!(entity::Identifier), - Registry, - _, - _, - _, - _, - _, - _, - _, - _, - >(); + is_disjoint::(); } } diff --git a/src/query/view/get.rs b/src/query/view/get.rs deleted file mode 100644 index bd079702..00000000 --- a/src/query/view/get.rs +++ /dev/null @@ -1,191 +0,0 @@ -use crate::{ - component, - entity, - query::{ - result::get::Index, - view, - view::{ - sealed::ViewsSealed, - View, - Views, - }, - }, -}; -use core::mem::MaybeUninit; - -pub trait Get<'a, T, I>: Views<'a> + Sized -where - T: View<'a>, -{ - type Remainder: Views<'a>; - - fn get(self) -> (T, Self::Remainder); - - fn get_maybe_uninit( - views: Self::MaybeUninit, - ) -> ( - T::MaybeUninit, - >::MaybeUninit, - ); - - fn get_index( - indices: Self::Indices, - ) -> (T::Index, >::Indices); -} - -impl<'a, T, V> Get<'a, &'a T, Index> for (&'a T, V) -where - V: Views<'a>, - T: component::Component, -{ - type Remainder = V; - - fn get(self) -> (&'a T, Self::Remainder) { - self - } - - fn get_maybe_uninit( - views: Self::MaybeUninit, - ) -> ( - MaybeUninit<&'a T>, - >::MaybeUninit, - ) { - views - } - - fn get_index(indices: Self::Indices) -> (usize, >::Indices) { - indices - } -} - -impl<'a, T, V> Get<'a, &'a mut T, Index> for (&'a mut T, V) -where - V: Views<'a>, - T: component::Component, -{ - type Remainder = V; - - fn get(self) -> (&'a mut T, Self::Remainder) { - self - } - - fn get_maybe_uninit( - views: Self::MaybeUninit, - ) -> ( - MaybeUninit<&'a mut T>, - >::MaybeUninit, - ) { - views - } - - fn get_index(indices: Self::Indices) -> (usize, >::Indices) { - indices - } -} - -impl<'a, T, V> Get<'a, Option<&'a T>, Index> for (Option<&'a T>, V) -where - V: Views<'a>, - T: component::Component, -{ - type Remainder = V; - - fn get(self) -> (Option<&'a T>, Self::Remainder) { - self - } - - fn get_maybe_uninit( - views: Self::MaybeUninit, - ) -> ( - Option<&'a T>, - >::MaybeUninit, - ) { - views - } - - fn get_index(indices: Self::Indices) -> (usize, >::Indices) { - indices - } -} - -impl<'a, T, V> Get<'a, Option<&'a mut T>, Index> for (Option<&'a mut T>, V) -where - V: Views<'a>, - T: component::Component, -{ - type Remainder = V; - - fn get(self) -> (Option<&'a mut T>, Self::Remainder) { - self - } - - fn get_maybe_uninit( - views: Self::MaybeUninit, - ) -> ( - Option<&'a mut T>, - >::MaybeUninit, - ) { - views - } - - fn get_index(indices: Self::Indices) -> (usize, >::Indices) { - indices - } -} - -impl<'a, V> Get<'a, entity::Identifier, Index> for (entity::Identifier, V) -where - V: Views<'a>, -{ - type Remainder = V; - - fn get(self) -> (entity::Identifier, Self::Remainder) { - self - } - - fn get_maybe_uninit( - views: Self::MaybeUninit, - ) -> ( - entity::Identifier, - >::MaybeUninit, - ) { - views - } - - fn get_index( - indices: Self::Indices, - ) -> (view::Null, >::Indices) { - indices - } -} - -impl<'a, I, T, V, W> Get<'a, T, (I,)> for (V, W) -where - V: View<'a>, - W: Get<'a, T, I>, - T: View<'a>, -{ - type Remainder = (V, >::Remainder); - - fn get(self) -> (T, Self::Remainder) { - let (target, remainder) = self.1.get(); - (target, (self.0, remainder)) - } - - fn get_maybe_uninit( - views: Self::MaybeUninit, - ) -> ( - T::MaybeUninit, - <(V, >::Remainder) as ViewsSealed<'a>>::MaybeUninit, - ) { - let (target, remainder) = W::get_maybe_uninit(views.1); - (target, (views.0, remainder)) - } - - fn get_index( - indices: Self::Indices, - ) -> (T::Index, >::Indices) { - let (target, remainder) = W::get_index(indices.1); - (target, (indices.0, remainder)) - } -} diff --git a/src/query/view/mod.rs b/src/query/view/mod.rs index 97327671..55b9c4d1 100644 --- a/src/query/view/mod.rs +++ b/src/query/view/mod.rs @@ -53,12 +53,10 @@ pub(crate) mod resource; mod contains; mod disjoint; -mod get; #[cfg(feature = "rayon")] mod merge; #[cfg(feature = "rayon")] mod par; -mod reshape; mod sealed; mod subset; @@ -76,7 +74,6 @@ pub(crate) use claim::{ Claim, Claims, }; -pub(crate) use get::Get; #[cfg(feature = "rayon")] pub(crate) use merge::Merge; #[cfg(feature = "rayon")] @@ -84,11 +81,10 @@ pub(crate) use par::{ ParViewsSeal, RepeatNone, }; -pub(crate) use reshape::Reshape; pub(crate) use sealed::ViewsSealed; use crate::{ - component::Component, + component, entity, hlist::define_null, }; @@ -140,13 +136,13 @@ use sealed::ViewSealed; /// [`World`]: crate::world::World pub trait View<'a>: ViewSealed<'a> {} -impl<'a, C> View<'a> for &'a C where C: Component {} +impl<'a, Component> View<'a> for &'a Component where Component: component::Component {} -impl<'a, C> View<'a> for &'a mut C where C: Component {} +impl<'a, Component> View<'a> for &'a mut Component where Component: component::Component {} -impl<'a, C> View<'a> for Option<&'a C> where C: Component {} +impl<'a, Component> View<'a> for Option<&'a Component> where Component: component::Component {} -impl<'a, C> View<'a> for Option<&'a mut C> where C: Component {} +impl<'a, Component> View<'a> for Option<&'a mut Component> where Component: component::Component {} impl<'a> View<'a> for entity::Identifier {} @@ -185,10 +181,10 @@ pub trait Views<'a>: ViewsSealed<'a> {} impl<'a> Views<'a> for Null {} -impl<'a, V, W> Views<'a> for (V, W) +impl<'a, View, Views> self::Views<'a> for (View, Views) where - V: View<'a>, - W: Views<'a>, + View: self::View<'a>, + Views: self::Views<'a>, { } diff --git a/src/query/view/par/mod.rs b/src/query/view/par/mod.rs index ccbbe82f..83dfd8e1 100644 --- a/src/query/view/par/mod.rs +++ b/src/query/view/par/mod.rs @@ -6,7 +6,7 @@ pub(crate) use seal::{ }; use crate::{ - component::Component, + component, entity, query::view::Null, }; @@ -40,13 +40,19 @@ use seal::ParViewSeal; #[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))] pub trait ParView<'a>: ParViewSeal<'a> + Send {} -impl<'a, C> ParView<'a> for &'a C where C: Component + Sync {} +impl<'a, Component> ParView<'a> for &'a Component where Component: component::Component + Sync {} -impl<'a, C> ParView<'a> for &'a mut C where C: Component + Send {} +impl<'a, Component> ParView<'a> for &'a mut Component where Component: component::Component + Send {} -impl<'a, C> ParView<'a> for Option<&'a C> where C: Component + Sync {} +impl<'a, Component> ParView<'a> for Option<&'a Component> where + Component: component::Component + Sync +{ +} -impl<'a, C> ParView<'a> for Option<&'a mut C> where C: Component + Send {} +impl<'a, Component> ParView<'a> for Option<&'a mut Component> where + Component: component::Component + Send +{ +} impl<'a> ParView<'a> for entity::Identifier {} @@ -84,9 +90,9 @@ pub trait ParViews<'a>: ParViewsSeal<'a> + Send {} impl<'a> ParViews<'a> for Null {} -impl<'a, V, W> ParViews<'a> for (V, W) +impl<'a, ParView, ParViews> self::ParViews<'a> for (ParView, ParViews) where - V: ParView<'a>, - W: ParViews<'a>, + ParView: self::ParView<'a>, + ParViews: self::ParViews<'a>, { } diff --git a/src/query/view/par/seal/mod.rs b/src/query/view/par/seal/mod.rs index 5ec1bf4c..b5391173 100644 --- a/src/query/view/par/seal/mod.rs +++ b/src/query/view/par/seal/mod.rs @@ -66,7 +66,7 @@ impl<'a> ParViewSeal<'a> for entity::Identifier { } pub trait ParViewsSeal<'a>: Views<'a> { - type ParResults: ParResults; + type ParResults: ParResults; } impl<'a> ParViewsSeal<'a> for Null { diff --git a/src/query/view/reshape.rs b/src/query/view/reshape.rs deleted file mode 100644 index 192523f6..00000000 --- a/src/query/view/reshape.rs +++ /dev/null @@ -1,70 +0,0 @@ -use crate::query::{ - result::reshape::Null, - view, - view::Get, -}; - -pub trait Reshape<'a, R, I>: view::Views<'a> + Sized -where - R: view::Views<'a>, -{ - fn reshape(self) -> R; - - fn reshape_maybe_uninit(views: Self::MaybeUninit) -> R::MaybeUninit; - - fn reshape_indices(indices: Self::Indices) -> R::Indices; -} - -impl Reshape<'_, view::Null, Null> for view::Null { - fn reshape(self) -> view::Null { - self - } - - fn reshape_maybe_uninit(views: view::Null) -> view::Null { - views - } - - fn reshape_indices(indices: view::Null) -> view::Null { - indices - } -} - -impl<'a, I, IS, R, S, T> Reshape<'a, (R, S), (I, IS)> for T -where - T: Get<'a, R, I> + view::Views<'a>, - T::Remainder: Reshape<'a, S, IS>, - R: view::View<'a>, - (R, S): view::Views<'a> - + view::ViewsSealed< - 'a, - Indices = ( - >::Index, - >::Indices, - ), - MaybeUninit = ( - >::MaybeUninit, - >::MaybeUninit, - ), - >, - S: view::Views<'a>, -{ - fn reshape(self) -> (R, S) { - let (target, remainder) = self.get(); - (target, remainder.reshape()) - } - - fn reshape_maybe_uninit( - views: Self::MaybeUninit, - ) -> <(R, S) as view::ViewsSealed<'a>>::MaybeUninit { - let (target, remainder) = T::get_maybe_uninit(views); - (target, T::Remainder::reshape_maybe_uninit(remainder)) - } - - fn reshape_indices(indices: Self::Indices) -> <(R, S) as view::ViewsSealed<'a>>::Indices { - let (target, remainder) = T::get_index(indices); - ( - target, - >::Remainder::reshape_indices(remainder), - ) - } -} diff --git a/src/query/view/subset.rs b/src/query/view/subset.rs index 98d047bc..7defb04c 100644 --- a/src/query/view/subset.rs +++ b/src/query/view/subset.rs @@ -93,8 +93,8 @@ where impl<'a, SubView, SubViews, Views, Index, Indices> Sealed<'a, Views, (Index, Indices)> for (SubView, SubViews) where - Views: Get<'a, SubView, Index> + view::Views<'a>, - >::Remainder: view::Views<'a>, + Views: SubViewable<'a, SubView, Index> + view::Views<'a>, + >::Remainder: view::Views<'a>, SubViews: Sealed<'a, Views::Remainder, Indices>, { unsafe fn view( @@ -121,7 +121,7 @@ where /// This `Get` implementation follows the "subset" rules defined for views. If the subview is /// contained within the superview, it can be found with this `Get` implementation. -pub trait Get<'a, View, Index>: view::Views<'a> + Sized { +pub trait SubViewable<'a, View, Index>: view::Views<'a> + Sized { type Remainder: view::Views<'a>; /// # Safety @@ -144,7 +144,7 @@ pub trait Get<'a, View, Index>: view::Views<'a> + Sized { Registry: registry::Registry; } -impl<'a, Component, Views> Get<'a, &'a Component, index::Index> for (&'a Component, Views) +impl<'a, Component, Views> SubViewable<'a, &'a Component, index::Index> for (&'a Component, Views) where Self: view::Views< 'a, @@ -178,7 +178,8 @@ where } } -impl<'a, Component, Views> Get<'a, &'a Component, index::Index> for (&'a mut Component, Views) +impl<'a, Component, Views> SubViewable<'a, &'a Component, index::Index> + for (&'a mut Component, Views) where Self: view::Views< 'a, @@ -212,7 +213,8 @@ where } } -impl<'a, Component, Views> Get<'a, &'a Component, index::Index> for (Option<&'a Component>, Views) +impl<'a, Component, Views> SubViewable<'a, &'a Component, index::Index> + for (Option<&'a Component>, Views) where Self: view::Views< 'a, @@ -246,7 +248,7 @@ where } } -impl<'a, Component, Views> Get<'a, &'a Component, index::Index> +impl<'a, Component, Views> SubViewable<'a, &'a Component, index::Index> for (Option<&'a mut Component>, Views) where Self: view::Views< @@ -281,7 +283,8 @@ where } } -impl<'a, Component, Views> Get<'a, &'a mut Component, index::Index> for (&'a mut Component, Views) +impl<'a, Component, Views> SubViewable<'a, &'a mut Component, index::Index> + for (&'a mut Component, Views) where Self: view::Views< 'a, @@ -315,7 +318,7 @@ where } } -impl<'a, Component, Views> Get<'a, &'a mut Component, index::Index> +impl<'a, Component, Views> SubViewable<'a, &'a mut Component, index::Index> for (Option<&'a mut Component>, Views) where Self: view::Views< @@ -350,7 +353,8 @@ where } } -impl<'a, Component, Views> Get<'a, Option<&'a Component>, index::Index> for (&'a Component, Views) +impl<'a, Component, Views> SubViewable<'a, Option<&'a Component>, index::Index> + for (&'a Component, Views) where Self: view::Views< 'a, @@ -390,7 +394,7 @@ where } } -impl<'a, Component, Views> Get<'a, Option<&'a Component>, index::Index> +impl<'a, Component, Views> SubViewable<'a, Option<&'a Component>, index::Index> for (&'a mut Component, Views) where Self: view::Views< @@ -431,7 +435,7 @@ where } } -impl<'a, Component, Views> Get<'a, Option<&'a Component>, index::Index> +impl<'a, Component, Views> SubViewable<'a, Option<&'a Component>, index::Index> for (Option<&'a Component>, Views) where Self: view::Views< @@ -461,7 +465,7 @@ where } } -impl<'a, Component, Views> Get<'a, Option<&'a Component>, index::Index> +impl<'a, Component, Views> SubViewable<'a, Option<&'a Component>, index::Index> for (Option<&'a mut Component>, Views) where Self: view::Views< @@ -495,7 +499,7 @@ where } } -impl<'a, Component, Views> Get<'a, Option<&'a mut Component>, index::Index> +impl<'a, Component, Views> SubViewable<'a, Option<&'a mut Component>, index::Index> for (&'a mut Component, Views) where Self: view::Views< @@ -536,7 +540,7 @@ where } } -impl<'a, Component, Views> Get<'a, Option<&'a mut Component>, index::Index> +impl<'a, Component, Views> SubViewable<'a, Option<&'a mut Component>, index::Index> for (Option<&'a mut Component>, Views) where Self: view::Views< @@ -566,7 +570,7 @@ where } } -impl<'a, Views> Get<'a, entity::Identifier, index::Index> for (entity::Identifier, Views) +impl<'a, Views> SubViewable<'a, entity::Identifier, index::Index> for (entity::Identifier, Views) where Self: view::Views< 'a, @@ -595,17 +599,20 @@ where } } -impl<'a, View, OtherView, Views, Index> Get<'a, View, (Index,)> for (OtherView, Views) +impl<'a, View, OtherView, Views, Index> SubViewable<'a, View, (Index,)> for (OtherView, Views) where Self: view::Views< 'a, MaybeUninit = (OtherView::MaybeUninit, Views::MaybeUninit), Indices = (OtherView::Index, Views::Indices), >, - Views: Get<'a, View, Index> + view::Views<'a>, + Views: SubViewable<'a, View, Index> + view::Views<'a>, OtherView: view::View<'a>, { - type Remainder = (OtherView, >::Remainder); + type Remainder = ( + OtherView, + >::Remainder, + ); unsafe fn view( views: Self::MaybeUninit, diff --git a/src/registry/clone/mod.rs b/src/registry/clone/mod.rs index 27297618..f54b0968 100644 --- a/src/registry/clone/mod.rs +++ b/src/registry/clone/mod.rs @@ -1,7 +1,7 @@ mod sealed; use crate::{ - component::Component, + component, registry::Null, }; use core::clone; @@ -15,9 +15,9 @@ pub trait Clone: Sealed {} impl Clone for Null {} -impl Clone for (C, R) +impl Clone for (Component, Registry) where - C: clone::Clone + Component, - R: Clone, + Component: clone::Clone + component::Component, + Registry: Clone, { } diff --git a/src/registry/contains/component/mod.rs b/src/registry/contains/component/mod.rs index 201cb9a1..142fa341 100644 --- a/src/registry/contains/component/mod.rs +++ b/src/registry/contains/component/mod.rs @@ -4,7 +4,10 @@ mod sealed; use sealed::Sealed; -/// Indicates that the component `C` is contained in the registry. -pub trait ContainsComponent: Sealed {} +/// Indicates that a component is contained in the registry. +pub trait ContainsComponent: Sealed {} -impl ContainsComponent for T where T: Sealed {} +impl ContainsComponent for Registry where + Registry: Sealed +{ +} diff --git a/src/registry/contains/entities/mod.rs b/src/registry/contains/entities/mod.rs index 650feed2..b9acb2c9 100644 --- a/src/registry/contains/entities/mod.rs +++ b/src/registry/contains/entities/mod.rs @@ -10,10 +10,9 @@ pub(crate) use sealed::Sealed; /// If the entities contain components not in this registry, attempting to use this trait will /// result in a compiler error, since the trait won't be implemented for the combination of entity /// and registry. -/// -/// This is generic over entities `E`, containments `P` (indicating whether each component is -/// contained in the registry), and indices `I` (indicating the location of each component in the -/// entity `E`). -pub trait ContainsEntities: Sealed {} +pub trait ContainsEntities: Sealed {} -impl ContainsEntities for T where T: Sealed {} +impl ContainsEntities for Registry where + Registry: Sealed +{ +} diff --git a/src/registry/contains/entities/sealed.rs b/src/registry/contains/entities/sealed.rs index 0990ba6a..494a1402 100644 --- a/src/registry/contains/entities/sealed.rs +++ b/src/registry/contains/entities/sealed.rs @@ -1,7 +1,7 @@ use crate::{ - component::Component, + component, entities, - entities::Entities, + hlist::Get, registry, registry::{ contains::{ @@ -26,22 +26,50 @@ use alloc::vec::Vec; /// This is generic over entities `E`, containments `P` (indicating whether each component is /// contained in the registry), and indices `I` (indicating the location of each component in the /// entity `E`). -pub trait Sealed: - Canonical<::Entity, Q> +pub trait Sealed: + Canonical<::Entity, Self::CanonicalContainments> { - /// The canonical form of the entity `E`. + /// The canonical form of the entities. /// /// This type is guaranteed to be canonical with respect to the current registry, and that /// relationship is embodied by an impl of the `Canonical` trait on the current registry. - type Canonical: Entities; + type Canonical: entities::Entities; + type CanonicalContainments; /// Returns the canonical form of the entities, consuming the original entities. - fn canonical(entities: E) -> Self::Canonical; + fn canonical(entities: Entities) -> Self::Canonical; } -impl Sealed for registry::Null +impl + Sealed for Registry where - Self: Canonical<::Entity, Q>, + Registry: Expanded, +{ + type Canonical = Registry::Canonical; + type CanonicalContainments = CanonicalContainments; + + fn canonical(entities: Entities) -> Self::Canonical { + Registry::canonical(entities) + } +} + +pub trait Expanded: + Canonical<::Entity, CanonicalContainments> +{ + /// The canonical form of the entities. + /// + /// This type is guaranteed to be canonical with respect to the current registry, and that + /// relationship is embodied by an impl of the `Canonical` trait on the current registry. + type Canonical: entities::Entities; + + /// Returns the canonical form of the entities, consuming the original entities. + fn canonical(entities: Entities) -> Self::Canonical; +} + +impl Expanded + for registry::Null +where + Self: Canonical<::Entity, CanonicalContainments>, { type Canonical = entities::Null; @@ -50,45 +78,75 @@ where } } -impl Sealed for (C, R) +impl< + Component, + Registry, + Entities, + Containments, + CanonicalContainment, + CanonicalContainments, + Index, + Indices, + > + Expanded< + Entities, + (Contained, Containments), + (CanonicalContainment, CanonicalContainments), + (Index, Indices), + > for (Component, Registry) where Self: Canonical< <( - Vec, - >::Remainder, P, QS, IS>>::Canonical, + Vec, + , Index>>::Remainder, + Containments, + CanonicalContainments, + Indices, + >>::Canonical, ) as entities::Contains>::Entity, - (Q, QS), + (CanonicalContainment, CanonicalContainments), + >, + Registry: Expanded< + , Index>>::Remainder, + Containments, + CanonicalContainments, + Indices, >, - R: Sealed<>::Remainder, P, QS, IS>, - E: entities::Get, - C: Component, + Entities: Get, Index>, + Component: component::Component, { type Canonical = ( - Vec, - >::Remainder, P, QS, IS>>::Canonical, + Vec, + , Index>>::Remainder, + Containments, + CanonicalContainments, + Indices, + >>::Canonical, ); - fn canonical(entities: E) -> Self::Canonical { + fn canonical(entities: Entities) -> Self::Canonical { let (component, remainder) = entities.get(); - (component, R::canonical(remainder)) + (component, Registry::canonical(remainder)) } } -impl Sealed for (C, R) +impl Expanded for (Component, Registry) where - Self: Canonical<<>::Canonical as entities::Contains>::Entity, (Q, QS)>, - R: Sealed, + Self: Canonical<<>::Canonical as entities::Contains>::Entity, (CanonicalContainment, CanonicalContainments)>, + Registry: Expanded, { - type Canonical = >::Canonical; + type Canonical = >::Canonical; - fn canonical(entities: E) -> Self::Canonical { - R::canonical(entities) + fn canonical(entities: Entities) -> Self::Canonical { + Registry::canonical(entities) } } #[cfg(test)] mod tests { - use super::*; + use super::Sealed; use crate::{ entities, Registry, diff --git a/src/registry/contains/entity/mod.rs b/src/registry/contains/entity/mod.rs index 5ca67f1c..65a91056 100644 --- a/src/registry/contains/entity/mod.rs +++ b/src/registry/contains/entity/mod.rs @@ -15,10 +15,9 @@ pub(crate) use sealed::Sealed; /// If the entity contains components not in this registry, attempting to use this trait will /// result in a compiler error, since the trait won't be implemented for the combination of entity /// and registry. -/// -/// This is generic over an entity `E`, containments `P` (indicating whether each component is -/// contained in the registry), and indices `I` (indicating the location of each component in the -/// entity `E`). -pub trait ContainsEntity: Sealed {} +pub trait ContainsEntity: Sealed {} -impl ContainsEntity for T where T: Sealed {} +impl ContainsEntity for Registry where + Registry: Sealed +{ +} diff --git a/src/registry/contains/entity/sealed.rs b/src/registry/contains/entity/sealed.rs index 42fda1fc..c7e23802 100644 --- a/src/registry/contains/entity/sealed.rs +++ b/src/registry/contains/entity/sealed.rs @@ -1,7 +1,7 @@ use crate::{ - component::Component, + component, entity, - entity::Entity, + hlist::Get, registry, registry::{ contains::{ @@ -13,20 +13,48 @@ use crate::{ }, }; -pub trait Sealed: Canonical { +pub trait Sealed: Canonical { /// The canonical form of the entity `E`. /// /// This type is guaranteed to be canonical with respect to the current registry, and that /// relationship is embodied by an impl of the `Canonical` trait on the current registry. - type Canonical: Entity; + type Canonical: entity::Entity; + type CanonicalContainments; /// Returns the canonical form of the entity, consuming the original entity. - fn canonical(entity: E) -> Self::Canonical; + fn canonical(entity: Entity) -> Self::Canonical; } -impl Sealed for registry::Null +impl + Sealed for Registry where - Self: Canonical, + Registry: Expanded, +{ + type Canonical = Registry::Canonical; + type CanonicalContainments = CanonicalContainments; + + fn canonical(entity: Entity) -> Self::Canonical { + Registry::canonical(entity) + } +} + +pub trait Expanded: + Canonical +{ + /// The canonical form of the entity `E`. + /// + /// This type is guaranteed to be canonical with respect to the current registry, and that + /// relationship is embodied by an impl of the `Canonical` trait on the current registry. + type Canonical: entity::Entity; + + /// Returns the canonical form of the entity, consuming the original entity. + fn canonical(entity: Entity) -> Self::Canonical; +} + +impl Expanded + for registry::Null +where + Self: Canonical, { type Canonical = entity::Null; @@ -35,36 +63,70 @@ where } } -impl Sealed for (C, R) +impl< + Component, + Registry, + Entity, + Containments, + CanonicalContainment, + CanonicalContainments, + Index, + Indices, + > + Expanded< + Entity, + (Contained, Containments), + (CanonicalContainment, CanonicalContainments), + (Index, Indices), + > for (Component, Registry) where Self: Canonical< ( - C, - >::Remainder, P, QS, IS>>::Canonical, + Component, + >::Remainder, + Containments, + CanonicalContainments, + Indices, + >>::Canonical, ), - (Q, QS), + (CanonicalContainment, CanonicalContainments), + >, + Registry: Expanded< + >::Remainder, + Containments, + CanonicalContainments, + Indices, >, - R: Sealed<>::Remainder, P, QS, IS>, - E: entity::Get, - C: Component, + Entity: Get, + Component: component::Component, { type Canonical = ( - C, - >::Remainder, P, QS, IS>>::Canonical, + Component, + >::Remainder, + Containments, + CanonicalContainments, + Indices, + >>::Canonical, ); - fn canonical(entity: E) -> Self::Canonical { + fn canonical(entity: Entity) -> Self::Canonical { let (component, remainder) = entity.get(); - (component, R::canonical(remainder)) + (component, Registry::canonical(remainder)) } } -impl Sealed for (C, R) +impl + Expanded for (C, R) where - Self: Canonical<>::Canonical, (Q, QS)>, - R: Sealed, + Self: Canonical< + >::Canonical, + (CanonicalContainment, CanonicalContainments), + >, + R: Expanded, { - type Canonical = >::Canonical; + type Canonical = >::Canonical; fn canonical(entity: E) -> Self::Canonical { R::canonical(entity) @@ -73,7 +135,7 @@ where #[cfg(test)] mod entity_tests { - use super::*; + use super::Sealed; use crate::{ entity, Registry, diff --git a/src/registry/contains/par_query/mod.rs b/src/registry/contains/par_query/mod.rs index a476e286..2bc6609e 100644 --- a/src/registry/contains/par_query/mod.rs +++ b/src/registry/contains/par_query/mod.rs @@ -5,15 +5,15 @@ use sealed::Sealed; #[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))] /// Indicates that a registry is queryable in parallel by the filter `F` and the views `V`. -pub trait ContainsParQuery<'a, F, FI, V, VI, P, I, Q>: Sealed<'a, F, FI, V, VI, P, I, Q> +pub trait ContainsParQuery<'a, Filter, Views, Indices>: Sealed<'a, Filter, Views, Indices> where - V: ParViews<'a>, + Views: ParViews<'a>, { } -impl<'a, R, F, V, FI, VI, P, I, Q> ContainsParQuery<'a, F, FI, V, VI, P, I, Q> for R +impl<'a, Registry, Filter, Views, Indices> ContainsParQuery<'a, Filter, Views, Indices> for Registry where - R: Sealed<'a, F, FI, V, VI, P, I, Q>, - V: ParViews<'a>, + Registry: Sealed<'a, Filter, Views, Indices>, + Views: ParViews<'a>, { } diff --git a/src/registry/contains/par_query/sealed.rs b/src/registry/contains/par_query/sealed.rs index e104c66c..8f88cc9d 100644 --- a/src/registry/contains/par_query/sealed.rs +++ b/src/registry/contains/par_query/sealed.rs @@ -6,16 +6,58 @@ use crate::query::view::ParViews; #[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))] /// Indicates that a registry is queryable in parallel by the filter `F` and the views `V`. -pub trait Sealed<'a, F, FI, V, VI, P, I, Q>: - ContainsFilter + ContainsFilter + ContainsParViews<'a, V, P, I, Q> +pub trait Sealed<'a, Filter, Views, Indices>: + ContainsFilter + + ContainsFilter + + ContainsParViews< + 'a, + Views, + Self::ViewsContainments, + Self::ViewsIndices, + Self::ViewsCanonicalContainments, + > where - V: ParViews<'a>, + Views: ParViews<'a>, { + type FilterIndices; + type ViewsFilterIndices; + type ViewsContainments; + type ViewsIndices; + type ViewsCanonicalContainments; } -impl<'a, R, F, V, FI, VI, P, I, Q> Sealed<'a, F, FI, V, VI, P, I, Q> for R +impl< + 'a, + Registry, + Filter, + Views, + FilterIndices, + ViewsFilterIndices, + ViewsContainments, + ViewsIndices, + ViewsCanonicalContainments, + > + Sealed< + 'a, + Filter, + Views, + ( + FilterIndices, + ViewsFilterIndices, + ViewsContainments, + ViewsIndices, + ViewsCanonicalContainments, + ), + > for Registry where - R: ContainsFilter + ContainsFilter + ContainsParViews<'a, V, P, I, Q>, - V: ParViews<'a>, + Registry: ContainsFilter + + ContainsFilter + + ContainsParViews<'a, Views, ViewsContainments, ViewsIndices, ViewsCanonicalContainments>, + Views: ParViews<'a>, { + type FilterIndices = FilterIndices; + type ViewsFilterIndices = ViewsFilterIndices; + type ViewsContainments = ViewsContainments; + type ViewsIndices = ViewsIndices; + type ViewsCanonicalContainments = ViewsCanonicalContainments; } diff --git a/src/registry/contains/par_views/sealed.rs b/src/registry/contains/par_views/sealed.rs index f0bc2505..51c99673 100644 --- a/src/registry/contains/par_views/sealed.rs +++ b/src/registry/contains/par_views/sealed.rs @@ -2,8 +2,11 @@ use crate::{ archetype, component::Component, entity, + hlist::{ + Get, + Reshape, + }, query::{ - result, view, view::{ ParViews, @@ -22,9 +25,12 @@ use crate::{ Registry, }, }; -use rayon::iter::{ - IntoParallelRefIterator, - ParallelIterator, +use rayon::{ + iter, + iter::{ + IntoParallelRefIterator, + ParallelIterator, + }, }; #[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))] @@ -57,7 +63,7 @@ where type Canonical: ParViews<'a, ParResults = Self::CanonicalResults>; /// The canonical form of the results of the views `V`. Equivalent to /// `Self::Canonical::Results`. - type CanonicalResults: result::Reshape; + type CanonicalResults: Reshape>; /// # Safety /// @@ -79,33 +85,33 @@ where impl<'a, I, IS, P, V, R, Q> ContainsParViewsOuter<'a, V, (Contained, P), (I, IS), Q> for (EntityIdentifierMarker, R) where - R: ContainsParViewsInner<'a, >::Remainder, P, IS> + R: ContainsParViewsInner<'a, >::Remainder, P, IS> + CanonicalParViews< 'a, >::Remainder, + >::Remainder, P, IS, >>::Canonical, P, >, - V: ParViews<'a> + view::Get<'a, entity::Identifier, I>, + V: ParViews<'a> + Get, ( rayon::iter::Cloned>, <>::Remainder, + >::Remainder, P, IS, >>::Canonical as ParViewsSeal<'a>>::ParResults, - ): result::Reshape<>::ParResults, Q>, + ): Reshape<>::ParResults, Q, iter::RepeatN>, { type Canonical = ( entity::Identifier, >::Remainder, + >::Remainder, P, IS, >>::Canonical, @@ -147,7 +153,7 @@ where + CanonicalParViews<'a, >::Canonical, P>, V: ParViews<'a>, <>::Canonical as ParViewsSeal<'a>>::ParResults: - result::Reshape<>::ParResults, Q>, + Reshape<>::ParResults, Q, iter::RepeatN>, { type Canonical = >::Canonical; type CanonicalResults = >::ParResults; @@ -180,48 +186,37 @@ impl ContainsParViewsInner<'_, view::Null, Null, Null> for registry::Null { impl<'a, C, I, IS, P, R, V> ContainsParViewsInner<'a, V, (&'a Contained, P), (I, IS)> for (C, R) where C: Component + Sync, - R: ContainsParViewsInner<'a, >::Remainder, P, IS>, - V: view::Get<'a, &'a C, I>, + R: ContainsParViewsInner<'a, >::Remainder, P, IS>, + V: Get<&'a C, I>, { type Canonical = ( &'a C, - >::Remainder, P, IS>>::Canonical, + >::Remainder, P, IS>>::Canonical, ); } impl<'a, C, I, IS, P, R, V> ContainsParViewsInner<'a, V, (&'a mut Contained, P), (I, IS)> for (C, R) where C: Component + Send, - R: ContainsParViewsInner<'a, >::Remainder, P, IS>, - V: view::Get<'a, &'a mut C, I>, + R: ContainsParViewsInner<'a, >::Remainder, P, IS>, + V: Get<&'a mut C, I>, { - type Canonical = - ( - &'a mut C, - >::Remainder, - P, - IS, - >>::Canonical, - ); + type Canonical = ( + &'a mut C, + >::Remainder, P, IS>>::Canonical, + ); } impl<'a, C, I, IS, P, R, V> ContainsParViewsInner<'a, V, (Option<&'a Contained>, P), (I, IS)> for (C, R) where C: Component + Sync, - R: ContainsParViewsInner<'a, , I>>::Remainder, P, IS>, - V: view::Get<'a, Option<&'a C>, I>, + R: ContainsParViewsInner<'a, , I>>::Remainder, P, IS>, + V: Get, I>, { type Canonical = ( Option<&'a C>, - , I>>::Remainder, - P, - IS, - >>::Canonical, + , I>>::Remainder, P, IS>>::Canonical, ); } @@ -229,14 +224,14 @@ impl<'a, C, I, IS, P, R, V> ContainsParViewsInner<'a, V, (Option<&'a mut Contain for (C, R) where C: Component + Send, - R: ContainsParViewsInner<'a, , I>>::Remainder, P, IS>, - V: view::Get<'a, Option<&'a mut C>, I>, + R: ContainsParViewsInner<'a, , I>>::Remainder, P, IS>, + V: Get, I>, { type Canonical = ( Option<&'a mut C>, , I>>::Remainder, + , I>>::Remainder, P, IS, >>::Canonical, diff --git a/src/registry/contains/query/mod.rs b/src/registry/contains/query/mod.rs index 3c0e1aa3..afc8c67d 100644 --- a/src/registry/contains/query/mod.rs +++ b/src/registry/contains/query/mod.rs @@ -1,18 +1,18 @@ mod sealed; -use crate::query::view::Views; +use crate::query::view; use sealed::Sealed; /// Indicates that a registry is queryable by the filter `F` and the views `V`. -pub trait ContainsQuery<'a, F, FI, V, VI, P, I, Q>: Sealed<'a, F, FI, V, VI, P, I, Q> +pub trait ContainsQuery<'a, Filter, Views, Indices>: Sealed<'a, Filter, Views, Indices> where - V: Views<'a>, + Views: view::Views<'a>, { } -impl<'a, R, F, V, FI, VI, P, I, Q> ContainsQuery<'a, F, FI, V, VI, P, I, Q> for R +impl<'a, Registry, Filter, Views, Indices> ContainsQuery<'a, Filter, Views, Indices> for Registry where - R: Sealed<'a, F, FI, V, VI, P, I, Q>, - V: Views<'a>, + Registry: Sealed<'a, Filter, Views, Indices>, + Views: view::Views<'a>, { } diff --git a/src/registry/contains/query/sealed.rs b/src/registry/contains/query/sealed.rs index a8f8ccf6..0d30c814 100644 --- a/src/registry/contains/query/sealed.rs +++ b/src/registry/contains/query/sealed.rs @@ -2,19 +2,63 @@ use super::super::{ ContainsFilter, ContainsViews, }; -use crate::query::view::Views; +use crate::query::view; /// Indicates that a registry is queryable by the filter `F` and the views `V`. -pub trait Sealed<'a, F, FI, V, VI, P, I, Q>: - ContainsFilter + ContainsFilter + ContainsViews<'a, V, P, I, Q> +pub trait Sealed<'a, Filter, Views, Indices>: + ContainsFilter + + ContainsFilter + + ContainsViews< + 'a, + Views, + ( + Self::ViewsContainments, + Self::ViewsIndices, + Self::ViewsCanonicalContainments, + ), + > where - V: Views<'a>, + Views: view::Views<'a>, { + type FilterIndices; + type ViewsFilterIndices; + type ViewsContainments; + type ViewsIndices; + type ViewsCanonicalContainments; } -impl<'a, R, F, V, FI, VI, P, I, Q> Sealed<'a, F, FI, V, VI, P, I, Q> for R +impl< + 'a, + Registry, + Filter, + Views, + FilterIndices, + ViewsFilterIndices, + ViewsContainments, + ViewsIndices, + ViewsCanonicalContainments, + > + Sealed< + 'a, + Filter, + Views, + ( + FilterIndices, + ViewsFilterIndices, + ViewsContainments, + ViewsIndices, + ViewsCanonicalContainments, + ), + > for Registry where - R: ContainsFilter + ContainsFilter + ContainsViews<'a, V, P, I, Q>, - V: Views<'a>, + Registry: ContainsFilter + + ContainsFilter + + ContainsViews<'a, Views, (ViewsContainments, ViewsIndices, ViewsCanonicalContainments)>, + Views: view::Views<'a>, { + type FilterIndices = FilterIndices; + type ViewsFilterIndices = ViewsFilterIndices; + type ViewsContainments = ViewsContainments; + type ViewsIndices = ViewsIndices; + type ViewsCanonicalContainments = ViewsCanonicalContainments; } diff --git a/src/registry/contains/views/mod.rs b/src/registry/contains/views/mod.rs index b4f78659..5b1ded12 100644 --- a/src/registry/contains/views/mod.rs +++ b/src/registry/contains/views/mod.rs @@ -5,21 +5,21 @@ pub(crate) use sealed::{ Sealed, }; -use crate::query::view::Views; +use crate::query::view; /// Indicates that all of the components viewed are contained in a registry. /// /// This allows reordering the components viewed into a canonical form, as well as reordering the /// results back to the originally requested form. -pub trait ContainsViews<'a, V, P, I, Q>: Sealed<'a, V, P, I, Q> +pub trait ContainsViews<'a, Views, Indices>: Sealed<'a, Views, Indices> where - V: Views<'a>, + Views: view::Views<'a>, { } -impl<'a, T, V, P, I, Q> ContainsViews<'a, V, P, I, Q> for T +impl<'a, Registry, Views, Indices> ContainsViews<'a, Views, Indices> for Registry where - T: Sealed<'a, V, P, I, Q>, - V: Views<'a>, + Registry: Sealed<'a, Views, Indices>, + Views: view::Views<'a>, { } diff --git a/src/registry/contains/views/sealed.rs b/src/registry/contains/views/sealed.rs index 9f582817..40e56a61 100644 --- a/src/registry/contains/views/sealed.rs +++ b/src/registry/contains/views/sealed.rs @@ -2,11 +2,13 @@ use crate::{ archetype, component::Component, entity, + hlist::{ + Get, + Reshape, + }, query::{ - result, view, view::{ - Reshape, Views, ViewsSealed, }, @@ -28,23 +30,37 @@ use core::{ slice, }; -pub trait Sealed<'a, V, P, I, Q>: Registry +pub trait Sealed<'a, Views, Indices>: Registry where - V: Views<'a>, + Views: view::Views<'a>, { - type Viewable: ContainsViewsOuter<'a, V, P, I, Q>; + type Containments; + type Indices; + type ReshapeIndices; + type Viewable: ContainsViewsOuter< + 'a, + Views, + Self::Containments, + Self::Indices, + Self::ReshapeIndices, + >; #[cfg(feature = "rayon")] #[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))] fn claims() -> Self::Claims; } -impl<'a, T, V, P, I, Q> Sealed<'a, V, P, I, Q> for T +impl<'a, Registry, Views, Containments, Indices, ReshapeIndices> + Sealed<'a, Views, (Containments, Indices, ReshapeIndices)> for Registry where - T: Registry, - V: Views<'a>, - (EntityIdentifierMarker, T): ContainsViewsOuter<'a, V, P, I, Q, Registry = T>, + Registry: registry::Registry, + Views: view::Views<'a>, + (EntityIdentifierMarker, Registry): + ContainsViewsOuter<'a, Views, Containments, Indices, ReshapeIndices, Registry = Registry>, { + type Containments = Containments; + type Indices = Indices; + type ReshapeIndices = ReshapeIndices; type Viewable = (EntityIdentifierMarker, Self); /// Return the dynamic claims over the components borrowed by the `Views`. @@ -71,10 +87,10 @@ where /// The canonical form of the views `V`. type Canonical: Views<'a> + ViewsSealed<'a, Results = Self::CanonicalResults> - + view::Reshape<'a, V, Q>; + + Reshape; /// The canonical form of the results of the views `V`. Equivalent to /// `Self::Canonical::Results`. - type CanonicalResults: result::Reshape; + type CanonicalResults: Reshape>>; /// # Safety /// @@ -117,7 +133,7 @@ where entity_identifiers: (*mut entity::Identifier, usize), length: usize, archetype_identifier: archetype::identifier::Iter, - ) -> >::MaybeUninit + ) -> V::MaybeUninit where R: Registry; @@ -136,38 +152,39 @@ where 'a, >::Remainder, + >::Remainder, P, IS, >>::Canonical, P, - > + ContainsViewsInner<'a, >::Remainder, P, IS>, - V: Views<'a> + view::Get<'a, entity::Identifier, I>, + > + ContainsViewsInner<'a, >::Remainder, P, IS>, + V: Views<'a> + Get, + V::Remainder: Views<'a>, <( entity::Identifier, >::Remainder, + >::Remainder, P, IS, >>::Canonical, - ) as ViewsSealed<'a>>::Results: result::Reshape<>::Results, Q>, + ) as ViewsSealed<'a>>::Results: Reshape<>::Results, Q, iter::Take>>, ( entity::Identifier, >::Remainder, + >::Remainder, P, IS, >>::Canonical, - ): view::Reshape<'a, V, Q> + ): Reshape + ViewsSealed< 'a, Results = ( iter::Copied>, <>::Remainder, + >::Remainder, P, IS, >>::Canonical as ViewsSealed<'a>>::Results, @@ -176,7 +193,7 @@ where view::Null, <>::Remainder, + >::Remainder, P, IS, >>::Canonical as ViewsSealed<'a>>::Indices, @@ -185,19 +202,37 @@ where entity::Identifier, <>::Remainder, + >::Remainder, P, IS, >>::Canonical as ViewsSealed<'a>>::MaybeUninit, ), >, + <( + entity::Identifier, + >::Remainder, + P, + IS, + >>::Canonical, + ) as ViewsSealed<'a>>::Indices: Reshape, + <( + entity::Identifier, + >::Remainder, + P, + IS, + >>::Canonical, + ) as ViewsSealed<'a>>::MaybeUninit: Reshape, { type Registry = R; type Canonical = ( entity::Identifier, >::Remainder, + >::Remainder, P, IS, >>::Canonical, @@ -259,7 +294,7 @@ where entity_identifiers: (*mut entity::Identifier, usize), length: usize, archetype_identifier: archetype::identifier::Iter, - ) -> >::MaybeUninit + ) -> V::MaybeUninit where R_: Registry, { @@ -275,7 +310,7 @@ where // `Vec`s of length `length` for each of the components identified by // `archetype_identifier`. `index` is guaranteed to be less than `length`. unsafe { R::view_one_maybe_uninit(index, columns, length, archetype_identifier) }, - ) + ).reshape() } #[cfg(feature = "rayon")] @@ -285,28 +320,19 @@ where } fn indices() -> V::Indices { - let canonical_indices = ( + ( view::Null, >::Remainder, + >::Remainder, P, IS, >>::Canonical, P, >>::indices::(), - ); - <( - entity::Identifier, - >::Remainder, - P, - IS, - >>::Canonical, - )>::reshape_indices(canonical_indices) + ).reshape() } } @@ -316,8 +342,12 @@ where R: CanonicalViews<'a, >::Canonical, P> + ContainsViewsInner<'a, V, P, I>, <>::Canonical as ViewsSealed<'a>>::Results: - result::Reshape<>::Results, Q>, - >::Canonical: view::Reshape<'a, V, Q>, + Reshape<>::Results, Q, iter::Take>>, + >::Canonical: Reshape, + <>::Canonical as ViewsSealed<'a>>::Indices: + Reshape, + <>::Canonical as ViewsSealed<'a>>::MaybeUninit: + Reshape, V: Views<'a>, { type Registry = R; @@ -361,12 +391,12 @@ where _entity_identifiers: (*mut entity::Identifier, usize), length: usize, archetype_identifier: archetype::identifier::Iter, - ) -> >::MaybeUninit + ) -> V::MaybeUninit where R_: Registry, { // SAFETY: The safety contract of this function applies to this function call. - unsafe { R::view_one_maybe_uninit(index, columns, length, archetype_identifier) } + unsafe { R::view_one_maybe_uninit(index, columns, length, archetype_identifier) }.reshape() } #[cfg(feature = "rayon")] @@ -376,8 +406,7 @@ where } fn indices() -> V::Indices { - let canonical_indices = R::indices::(); - Self::Canonical::reshape_indices(canonical_indices) + R::indices::().reshape() } } @@ -395,24 +424,26 @@ impl<'a> ContainsViewsInner<'a, view::Null, Null, Null> for registry::Null { impl<'a, C, I, IS, P, R, V> ContainsViewsInner<'a, V, (&'a Contained, P), (I, IS)> for (C, R) where C: Component, - R: ContainsViewsInner<'a, >::Remainder, P, IS>, - V: Views<'a> + view::Get<'a, &'a C, I>, + R: ContainsViewsInner<'a, >::Remainder, P, IS>, + V: Views<'a> + Get<&'a C, I>, + V::Remainder: Views<'a>, { type Canonical = ( &'a C, - >::Remainder, P, IS>>::Canonical, + >::Remainder, P, IS>>::Canonical, ); } impl<'a, C, I, IS, P, R, V> ContainsViewsInner<'a, V, (&'a mut Contained, P), (I, IS)> for (C, R) where C: Component, - R: ContainsViewsInner<'a, >::Remainder, P, IS>, - V: Views<'a> + view::Get<'a, &'a mut C, I>, + R: ContainsViewsInner<'a, >::Remainder, P, IS>, + V: Views<'a> + Get<&'a mut C, I>, + V::Remainder: Views<'a>, { type Canonical = ( &'a mut C, - >::Remainder, P, IS>>::Canonical, + >::Remainder, P, IS>>::Canonical, ); } @@ -420,33 +451,29 @@ impl<'a, C, I, IS, P, R, V> ContainsViewsInner<'a, V, (Option<&'a Contained>, P) for (C, R) where C: Component, - R: ContainsViewsInner<'a, , I>>::Remainder, P, IS>, - V: Views<'a> + view::Get<'a, Option<&'a C>, I>, + R: ContainsViewsInner<'a, , I>>::Remainder, P, IS>, + V: Views<'a> + Get, I>, + V::Remainder: Views<'a>, { - type Canonical = - ( - Option<&'a C>, - , I>>::Remainder, - P, - IS, - >>::Canonical, - ); + type Canonical = ( + Option<&'a C>, + , I>>::Remainder, P, IS>>::Canonical, + ); } impl<'a, C, I, IS, P, R, V> ContainsViewsInner<'a, V, (Option<&'a mut Contained>, P), (I, IS)> for (C, R) where C: Component, - R: ContainsViewsInner<'a, , I>>::Remainder, P, IS>, - V: Views<'a> + view::Get<'a, Option<&'a mut C>, I>, + R: ContainsViewsInner<'a, , I>>::Remainder, P, IS>, + V: Views<'a> + Get, I>, + V::Remainder: Views<'a>, { type Canonical = ( Option<&'a mut C>, , I>>::Remainder, + , I>>::Remainder, P, IS, >>::Canonical, @@ -456,14 +483,15 @@ where impl<'a, I, IS, P, V, R> ContainsViewsInner<'a, V, (Contained, P), (I, IS)> for (EntityIdentifierMarker, R) where - R: ContainsViewsInner<'a, >::Remainder, P, IS>, - V: Views<'a> + view::Get<'a, entity::Identifier, I>, + R: ContainsViewsInner<'a, >::Remainder, P, IS>, + V: Views<'a> + Get, + V::Remainder: Views<'a>, { type Canonical = ( entity::Identifier, >::Remainder, + >::Remainder, P, IS, >>::Canonical, diff --git a/src/registry/debug/mod.rs b/src/registry/debug/mod.rs index 192caaa1..41b58f13 100644 --- a/src/registry/debug/mod.rs +++ b/src/registry/debug/mod.rs @@ -1,7 +1,7 @@ mod sealed; use crate::{ - component::Component, + component, registry::Null, }; use core::fmt; @@ -17,9 +17,9 @@ pub trait Debug: Sealed {} impl Debug for Null {} -impl Debug for (C, R) +impl Debug for (Component, Registry) where - C: Component + fmt::Debug, - R: Debug, + Component: component::Component + fmt::Debug, + Registry: Debug, { } diff --git a/src/registry/eq/mod.rs b/src/registry/eq/mod.rs index 6a0dc269..fc9697b2 100644 --- a/src/registry/eq/mod.rs +++ b/src/registry/eq/mod.rs @@ -1,7 +1,7 @@ mod sealed; use crate::{ - component::Component, + component, registry::Null, }; use core::cmp; @@ -17,10 +17,10 @@ pub trait PartialEq: Sealed {} impl PartialEq for Null {} -impl PartialEq for (C, R) +impl PartialEq for (Component, Registry) where - C: Component + cmp::PartialEq, - R: PartialEq, + Component: component::Component + cmp::PartialEq, + Registry: PartialEq, { } @@ -34,9 +34,9 @@ pub trait Eq: PartialEq {} impl Eq for Null {} -impl Eq for (C, R) +impl Eq for (Component, Registry) where - C: Component + cmp::Eq, - R: Eq, + Component: component::Component + cmp::Eq, + Registry: Eq, { } diff --git a/src/registry/get.rs b/src/registry/get.rs deleted file mode 100644 index 51ec08a6..00000000 --- a/src/registry/get.rs +++ /dev/null @@ -1,16 +0,0 @@ -pub struct Index; - -pub trait Get { - type Remainder; -} - -impl Get for (T, U) { - type Remainder = U; -} - -impl Get for (U, V) -where - V: Get, -{ - type Remainder = (U, >::Remainder); -} diff --git a/src/registry/mod.rs b/src/registry/mod.rs index a3d03172..82e58186 100644 --- a/src/registry/mod.rs +++ b/src/registry/mod.rs @@ -32,7 +32,6 @@ pub(crate) mod contains; mod clone; mod debug; mod eq; -mod get; mod sealed; #[cfg(feature = "serde")] mod serde; @@ -60,7 +59,6 @@ pub use eq::{ #[cfg(feature = "rayon")] pub(crate) use contains::ContainsParViews; -pub(crate) use get::Get; #[cfg(feature = "rayon")] pub(crate) use sealed::CanonicalParViews; pub(crate) use sealed::{ @@ -70,7 +68,7 @@ pub(crate) use sealed::{ }; use crate::{ - component::Component, + component, hlist::define_null_uninstantiable, }; use sealed::Sealed; @@ -105,10 +103,10 @@ pub trait Registry: Sealed + 'static {} impl Registry for Null {} -impl Registry for (C, R) +impl self::Registry for (Component, Registry) where - C: Component, - R: Registry, + Component: component::Component, + Registry: self::Registry, { } diff --git a/src/registry/serde/de/mod.rs b/src/registry/serde/de/mod.rs index abec0712..53771b1a 100644 --- a/src/registry/serde/de/mod.rs +++ b/src/registry/serde/de/mod.rs @@ -1,7 +1,7 @@ mod sealed; use crate::{ - component::Component, + component, registry::Null, }; use sealed::Sealed; @@ -17,9 +17,9 @@ pub trait Deserialize<'de>: Sealed<'de> {} impl<'de> Deserialize<'de> for Null {} -impl<'de, C, R> Deserialize<'de> for (C, R) +impl<'de, Component, Registry> Deserialize<'de> for (Component, Registry) where - C: Component + serde::Deserialize<'de>, - R: Deserialize<'de>, + Component: component::Component + serde::Deserialize<'de>, + Registry: Deserialize<'de>, { } diff --git a/src/registry/serde/ser/mod.rs b/src/registry/serde/ser/mod.rs index 7fb0f525..aa2758e2 100644 --- a/src/registry/serde/ser/mod.rs +++ b/src/registry/serde/ser/mod.rs @@ -1,7 +1,7 @@ mod sealed; use crate::{ - component::Component, + component, registry::Null, }; use sealed::Sealed; @@ -17,9 +17,9 @@ pub trait Serialize: Sealed {} impl Serialize for Null {} -impl Serialize for (C, R) +impl Serialize for (Component, Registry) where - C: Component + serde::Serialize, - R: Serialize, + Component: component::Component + serde::Serialize, + Registry: Serialize, { } diff --git a/src/resource/contains/views.rs b/src/resource/contains/views.rs index 359417bd..00c4aa75 100644 --- a/src/resource/contains/views.rs +++ b/src/resource/contains/views.rs @@ -17,26 +17,36 @@ use crate::{ }; /// Indicates that all of the viewed resources are contained in the list of resources. -pub trait ContainsViews<'a, Views, Containments, Indices, CanonicalContainments, ReshapeIndices>: - Sealed<'a, Views, Containments, Indices, CanonicalContainments, ReshapeIndices> +pub trait ContainsViews<'a, Views, Indices>: Sealed<'a, Views, Indices> {} + +impl<'a, Resources, Views, Indices> ContainsViews<'a, Views, Indices> for Resources where + Resources: Sealed<'a, Views, Indices> { } +pub trait Sealed<'a, Views, Indices> { + fn view(&'a mut self) -> Views; +} + impl<'a, Resources, Views, Containments, Indices, CanonicalContainments, ReshapeIndices> - ContainsViews<'a, Views, Containments, Indices, CanonicalContainments, ReshapeIndices> - for Resources + Sealed<'a, Views, (Containments, Indices, CanonicalContainments, ReshapeIndices)> for Resources where - Resources: Sealed<'a, Views, Containments, Indices, CanonicalContainments, ReshapeIndices>, + Resources: Expanded<'a, Views, Containments, Indices, CanonicalContainments, ReshapeIndices>, { + fn view(&'a mut self) -> Views { + self.view() + } } -pub trait Sealed<'a, Views, Containments, Indices, CanonicalContainments, ReshapeIndices> { +pub trait Expanded<'a, Views, Containments, Indices, CanonicalContainments, ReshapeIndices> { + /// The canonical form of the `Views` with respect to the resources. type Canonical: Reshape; fn view(&'a mut self) -> Views; } -impl<'a, ReshapeIndices> Sealed<'a, view::Null, Null, Null, Null, ReshapeIndices> for resource::Null +impl<'a, ReshapeIndices> Expanded<'a, view::Null, Null, Null, Null, ReshapeIndices> + for resource::Null where view::Null: Reshape, { @@ -57,7 +67,7 @@ impl< CanonicalContainments, ReshapeIndices, > - Sealed< + Expanded< 'a, Views, (NotContained, Containments), @@ -66,7 +76,7 @@ impl< ReshapeIndices, > for (Resource, Resources) where - Resources: Sealed<'a, Views, Containments, Indices, CanonicalContainments, ReshapeIndices>, + Resources: Expanded<'a, Views, Containments, Indices, CanonicalContainments, ReshapeIndices>, { type Canonical = Resources::Canonical; @@ -88,7 +98,7 @@ impl< ReshapeIndex, ReshapeIndices, > - Sealed< + Expanded< 'a, Views, (Contained, Containments), @@ -98,8 +108,14 @@ impl< > for (Resource, Resources) where Views: view::resource::Get, - Resources: - Sealed<'a, Views::Remainder, Containments, Indices, CanonicalContainments, ReshapeIndices>, + Resources: Expanded< + 'a, + Views::Remainder, + Containments, + Indices, + CanonicalContainments, + ReshapeIndices, + >, (Resource, Resources): CanonicalViews< 'a, (Views::View, Resources::Canonical), diff --git a/src/system/mod.rs b/src/system/mod.rs index 1a5b9a8f..6dc11337 100644 --- a/src/system/mod.rs +++ b/src/system/mod.rs @@ -13,7 +13,7 @@ //! Result, //! Views, //! }, -//! registry::ContainsQuery, +//! registry, //! system::System, //! }; //! @@ -30,18 +30,12 @@ //! type ResourceViews<'a> = Views!(); //! type EntryViews<'a> = Views!(); //! -//! fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( +//! fn run<'a, R, S, I, E>( //! &mut self, -//! query_results: Result< -//! R, -//! S, -//! result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, -//! Self::ResourceViews<'a>, -//! Self::EntryViews<'a>, -//! (EP, EI, EQ), -//! >, +//! query_results: Result, Self::EntryViews<'a>, E>, //! ) where -//! R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, +//! R: registry::Registry, +//! I: Iterator>, //! { //! for result!(foo, bar) in query_results.iter { //! if bar.0 { @@ -77,15 +71,10 @@ pub use schedule::{ use crate::{ query::{ - filter::Filter, - result, view::Views, Result, }, - registry::{ - ContainsQuery, - ContainsViews, - }, + registry::ContainsViews, }; /// An executable type which operates over the entities within a [`World`]. @@ -108,7 +97,7 @@ use crate::{ /// Result, /// Views, /// }, -/// registry::ContainsQuery, +/// registry, /// system::System, /// }; /// @@ -125,18 +114,12 @@ use crate::{ /// type ResourceViews<'a> = Views!(); /// type EntryViews<'a> = Views!(); /// -/// fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( +/// fn run<'a, R, S, I, E>( /// &mut self, -/// query_results: Result< -/// R, -/// S, -/// result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, -/// Self::ResourceViews<'a>, -/// Self::EntryViews<'a>, -/// (EP, EI, EQ), -/// >, +/// query_results: Result, Self::EntryViews<'a>, E>, /// ) where -/// R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, +/// R: registry::Registry, +/// I: Iterator>, /// { /// for result!(foo, bar) in query_results.iter { /// if bar.0 { @@ -151,9 +134,9 @@ use crate::{ /// [`World`]: crate::world::World pub trait System { /// The filter to apply to queries run by this system. - type Filter: Filter; + type Filter; /// The views on components this system should operate on. - type Views<'a>: Views<'a> + Filter; + type Views<'a>: Views<'a>; /// Views on resources. /// /// The system will have access to the resources requested here when run. @@ -183,7 +166,7 @@ pub trait System { /// Result, /// Views, /// }, - /// registry::ContainsQuery, + /// registry, /// system::System, /// }; /// @@ -200,18 +183,12 @@ pub trait System { /// type ResourceViews<'a> = Views!(); /// type EntryViews<'a> = Views!(); /// - /// fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + /// fn run<'a, R, S, I, E>( /// &mut self, - /// query_results: Result< - /// R, - /// S, - /// result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - /// Self::ResourceViews<'a>, - /// Self::EntryViews<'a>, - /// (EP, EI, EQ), - /// >, + /// query_results: Result, Self::EntryViews<'a>, E>, /// ) where - /// R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + /// R: registry::Registry, + /// I: Iterator>, /// { /// for result!(foo, bar) in query_results.iter { /// if bar.0 { @@ -223,18 +200,10 @@ pub trait System { /// ``` /// /// [`World`]: crate::world::World - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_result: Result< - 'a, - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_result: Result<'a, R, S, I, Self::ResourceViews<'a>, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q> - + ContainsViews<'a, Self::EntryViews<'a>, EP, EI, EQ>; + R: ContainsViews<'a, Self::EntryViews<'a>, E>, + I: Iterator>; } diff --git a/src/system/par.rs b/src/system/par.rs index d2c6c5cb..a8724bec 100644 --- a/src/system/par.rs +++ b/src/system/par.rs @@ -1,18 +1,14 @@ use crate::{ query::{ - filter::Filter, - result, view::{ ParViews, Views, }, Result, }, - registry::{ - ContainsParQuery, - ContainsViews, - }, + registry::ContainsViews, }; +use rayon::iter::ParallelIterator; /// An executable type which operates over the entities within a [`World`] in parallel. /// @@ -30,7 +26,7 @@ use crate::{ /// Result, /// Views, /// }, -/// registry::ContainsParQuery, +/// registry, /// system::ParSystem, /// }; /// use rayon::iter::ParallelIterator; @@ -48,18 +44,12 @@ use crate::{ /// type ResourceViews<'a> = Views!(); /// type EntryViews<'a> = Views!(); /// -/// fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( +/// fn run<'a, R, S, I, E>( /// &mut self, -/// query_results: Result< -/// R, -/// S, -/// result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, -/// Self::ResourceViews<'a>, -/// Self::EntryViews<'a>, -/// (EP, EI, EQ), -/// >, +/// query_results: Result, Self::EntryViews<'a>, E>, /// ) where -/// R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, +/// R: registry::Registry, +/// I: ParallelIterator>, /// { /// query_results.iter.for_each(|result!(foo, bar)| { /// if bar.0 { @@ -79,9 +69,9 @@ use crate::{ #[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))] pub trait ParSystem { /// The filter to apply to queries run by this system. - type Filter: Filter; + type Filter; /// The views on components this system should operate on. - type Views<'a>: ParViews<'a> + Filter; + type Views<'a>: ParViews<'a>; /// Views on resources. /// /// The system will have access to the resources requested here when run. @@ -111,7 +101,7 @@ pub trait ParSystem { /// Result, /// Views, /// }, - /// registry::ContainsParQuery, + /// registry, /// system::ParSystem, /// }; /// use rayon::iter::ParallelIterator; @@ -129,18 +119,12 @@ pub trait ParSystem { /// type ResourceViews<'a> = Views!(); /// type EntryViews<'a> = Views!(); /// - /// fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + /// fn run<'a, R, S, I, E>( /// &mut self, - /// query_results: Result< - /// R, - /// S, - /// result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - /// Self::ResourceViews<'a>, - /// Self::EntryViews<'a>, - /// (EP, EI, EQ), - /// >, + /// query_results: Result, Self::EntryViews<'a>, E>, /// ) where - /// R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + /// R: registry::Registry, + /// I: ParallelIterator>, /// { /// query_results.iter.for_each(|result!(foo, bar)| { /// if bar.0 { @@ -152,18 +136,10 @@ pub trait ParSystem { /// ``` /// /// [`World`]: crate::world::World - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_result: Result< - 'a, - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_result: Result<'a, R, S, I, Self::ResourceViews<'a>, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q> - + ContainsViews<'a, Self::EntryViews<'a>, EP, EI, EQ>; + R: ContainsViews<'a, Self::EntryViews<'a>, E>, + I: ParallelIterator>; } diff --git a/src/system/schedule/claim/get/mod.rs b/src/system/schedule/claim/get/mod.rs deleted file mode 100644 index 751e0ec2..00000000 --- a/src/system/schedule/claim/get/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub(crate) mod registry; -pub(crate) mod views; diff --git a/src/system/schedule/claim/get/registry.rs b/src/system/schedule/claim/get/registry.rs deleted file mode 100644 index 51ec08a6..00000000 --- a/src/system/schedule/claim/get/registry.rs +++ /dev/null @@ -1,16 +0,0 @@ -pub struct Index; - -pub trait Get { - type Remainder; -} - -impl Get for (T, U) { - type Remainder = U; -} - -impl Get for (U, V) -where - V: Get, -{ - type Remainder = (U, >::Remainder); -} diff --git a/src/system/schedule/claim/get/views.rs b/src/system/schedule/claim/get/views.rs deleted file mode 100644 index 8a4740df..00000000 --- a/src/system/schedule/claim/get/views.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub struct Index; - -pub trait Get {} - -impl Get for (T, U) {} - -impl Get for (U, V) where V: Get {} diff --git a/src/system/schedule/claim/inverse.rs b/src/system/schedule/claim/inverse.rs index e2e6993b..c1a6810b 100644 --- a/src/system/schedule/claim/inverse.rs +++ b/src/system/schedule/claim/inverse.rs @@ -1,8 +1,10 @@ use crate::{ entity, - hlist::define_null, + hlist::{ + define_null, + Get, + }, query::view, - system::schedule::claim::get::registry::Get, }; define_null!(); diff --git a/src/system/schedule/claim/mod.rs b/src/system/schedule/claim/mod.rs index 8fce36a7..cb64b55b 100644 --- a/src/system/schedule/claim/mod.rs +++ b/src/system/schedule/claim/mod.rs @@ -1,6 +1,5 @@ pub(crate) mod decision; -mod get; mod inverse; mod merger; mod verifier; diff --git a/src/system/schedule/claim/verifier.rs b/src/system/schedule/claim/verifier.rs index 387517e7..633fbc77 100644 --- a/src/system/schedule/claim/verifier.rs +++ b/src/system/schedule/claim/verifier.rs @@ -1,14 +1,11 @@ use crate::{ entity, - hlist::define_null, - query::view, - system::schedule::claim::{ - decision, - get::{ - registry, - views, - }, + hlist::{ + define_null, + Get, }, + query::view, + system::schedule::claim::decision, }; define_null!(); @@ -44,7 +41,7 @@ impl<'a, R, C> Verifier<'a, R, C, Null, Null> for view::Null { /// Not present in the claims. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (NotPresent, P)> for (&'a T, U) where - R: registry::Get, + R: Get, U: Verifier<'a, R, C, IS, P>, { type Decision = >::Decision; @@ -53,7 +50,7 @@ where /// Not present in the claims. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (NotPresent, P)> for (&'a mut T, U) where - R: registry::Get, + R: Get, U: Verifier<'a, R, C, IS, P>, { type Decision = >::Decision; @@ -62,7 +59,7 @@ where /// Not present in the claims. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (NotPresent, P)> for (Option<&'a T>, U) where - R: registry::Get, + R: Get, U: Verifier<'a, R, C, IS, P>, { type Decision = >::Decision; @@ -72,7 +69,7 @@ where impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (NotPresent, P)> for (Option<&'a mut T>, U) where - R: registry::Get, + R: Get, U: Verifier<'a, R, C, IS, P>, { type Decision = >::Decision; @@ -81,7 +78,7 @@ where /// Multiple immutable references are acceptable. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (ImmutImmut, P)> for (&'a T, U) where - C: views::Get<&'a T, I>, + C: Get<&'a T, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = >::Decision; @@ -90,7 +87,7 @@ where /// Multiple immutable references are acceptable. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (ImmutImmut, P)> for (Option<&'a T>, U) where - C: views::Get<&'a T, I>, + C: Get<&'a T, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = >::Decision; @@ -99,7 +96,7 @@ where /// Multiple immutable references are acceptable. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (ImmutOptionImmut, P)> for (&'a T, U) where - C: views::Get, I>, + C: Get, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = >::Decision; @@ -109,7 +106,7 @@ where impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (ImmutOptionImmut, P)> for (Option<&'a T>, U) where - C: views::Get, I>, + C: Get, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = >::Decision; @@ -130,7 +127,7 @@ where /// Previously borrowed as mutable. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (ImmutMut, P)> for (&'a T, U) where - C: views::Get<&'a mut T, I>, + C: Get<&'a mut T, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = decision::Cut; @@ -139,7 +136,7 @@ where /// Previously borrowed as mutable. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (ImmutOptionMut, P)> for (&'a T, U) where - C: views::Get, I>, + C: Get, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = decision::Cut; @@ -148,7 +145,7 @@ where /// Previously borrowed as mutable. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (ImmutMut, P)> for (Option<&'a T>, U) where - C: views::Get<&'a mut T, I>, + C: Get<&'a mut T, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = decision::Cut; @@ -158,7 +155,7 @@ where impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (ImmutOptionMut, P)> for (Option<&'a T>, U) where - C: views::Get, I>, + C: Get, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = decision::Cut; @@ -167,7 +164,7 @@ where /// Previously borrowed as mutable. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (MutMut, P)> for (&'a mut T, U) where - C: views::Get<&'a mut T, I>, + C: Get<&'a mut T, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = decision::Cut; @@ -176,7 +173,7 @@ where /// Previously borrowed as mutable. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (MutOptionMut, P)> for (&'a mut T, U) where - C: views::Get, I>, + C: Get, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = decision::Cut; @@ -185,7 +182,7 @@ where /// Previously borrowed as mutable. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (MutMut, P)> for (Option<&'a mut T>, U) where - C: views::Get<&'a mut T, I>, + C: Get<&'a mut T, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = decision::Cut; @@ -195,7 +192,7 @@ where impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (MutOptionMut, P)> for (Option<&'a mut T>, U) where - C: views::Get, I>, + C: Get, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = decision::Cut; @@ -204,7 +201,7 @@ where /// Previously borrowed as immutable. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (MutImmut, P)> for (&'a mut T, U) where - C: views::Get<&'a T, I>, + C: Get<&'a T, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = decision::Cut; @@ -213,7 +210,7 @@ where /// Previously borrowed as immutable. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (MutOptionImmut, P)> for (&'a mut T, U) where - C: views::Get, I>, + C: Get, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = decision::Cut; @@ -222,7 +219,7 @@ where /// Previously borrowed as immutable. impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (MutImmut, P)> for (Option<&'a mut T>, U) where - C: views::Get<&'a T, I>, + C: Get<&'a T, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = decision::Cut; @@ -232,7 +229,7 @@ where impl<'a, R, C, I, IS, T, U, P> Verifier<'a, R, C, (I, IS), (MutOptionImmut, P)> for (Option<&'a mut T>, U) where - C: views::Get, I>, + C: Get, I>, U: Verifier<'a, R, C, IS, P>, { type Decision = decision::Cut; diff --git a/src/system/schedule/mod.rs b/src/system/schedule/mod.rs index 52b5248a..cbb47566 100644 --- a/src/system/schedule/mod.rs +++ b/src/system/schedule/mod.rs @@ -17,7 +17,7 @@ //! Result, //! Views, //! }, -//! registry::ContainsQuery, +//! registry, //! system::{ //! schedule, //! schedule::task, @@ -38,18 +38,12 @@ //! type ResourceViews<'a> = Views!(); //! type EntryViews<'a> = Views!(); //! -//! fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( +//! fn run<'a, R, S, I, E>( //! &mut self, -//! query_results: Result< -//! R, -//! S, -//! result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, -//! Self::ResourceViews<'a>, -//! Self::EntryViews<'a>, -//! (EP, EI, EQ), -//! >, +//! query_results: Result, Self::EntryViews<'a>, E>, //! ) where -//! R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, +//! R: registry::Registry, +//! I: Iterator>, //! { //! for result!(foo, bar) in query_results.iter { //! // Do something... @@ -65,18 +59,12 @@ //! type ResourceViews<'a> = Views!(); //! type EntryViews<'a> = Views!(); //! -//! fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( +//! fn run<'a, R, S, I, E>( //! &mut self, -//! query_results: Result< -//! R, -//! S, -//! result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, -//! Self::ResourceViews<'a>, -//! Self::EntryViews<'a>, -//! (EP, EI, EQ), -//! >, +//! query_results: Result, Self::EntryViews<'a>, E>, //! ) where -//! R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, +//! R: registry::Registry, +//! I: Iterator>, //! { //! for result!(baz, bar) in query_results.iter { //! // Do something... @@ -106,7 +94,7 @@ pub(crate) use stages::Stages; use crate::{ doc, - registry::Registry, + registry, }; use scheduler::Scheduler; use sealed::Sealed; @@ -126,173 +114,17 @@ use task::Task; /// [`schedule!`]: crate::system::schedule! /// [`System`]: crate::system::System /// [`Views`]: trait@crate::query::view::Views -pub trait Schedule< - 'a, - R, - Resources, - I, - P, - RI, - MergeParametersList, - ResourcesIndicesLists, - ResourcesContainmentsLists, - ResourcesInverseIndicesLists, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsLists, - ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, - EntryIndicesLists, - EntryReshapeIndicesLists, ->: - Sealed< - 'a, - R, - Resources, - I, - P, - RI, - MergeParametersList, - ResourcesIndicesLists, - ResourcesContainmentsLists, - ResourcesInverseIndicesLists, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsLists, - ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, - EntryIndicesLists, - EntryReshapeIndicesLists, -> where - R: Registry, +pub trait Schedule<'a, Registry, Resources, Indices>: + Sealed<'a, Registry, Resources, Indices> +where + Registry: registry::Registry, { } -impl< - 'a, - R, - Resources, - T, - I, - P, - RI, - MergeParametersList, - ResourcesIndicesLists, - ResourcesContainmentsLists, - ResourcesInverseIndicesLists, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsLists, - ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, - EntryIndicesLists, - EntryReshapeIndicesLists, - > - Schedule< - 'a, - R, - Resources, - I, - P, - RI, - MergeParametersList, - ResourcesIndicesLists, - ResourcesContainmentsLists, - ResourcesInverseIndicesLists, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsLists, - ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, - EntryIndicesLists, - EntryReshapeIndicesLists, - > for T +impl<'a, T, Registry, Resources, Indices> Schedule<'a, Registry, Resources, Indices> for T where - R: Registry, - T: Sealed< - 'a, - R, - Resources, - I, - P, - RI, - MergeParametersList, - ResourcesIndicesLists, - ResourcesContainmentsLists, - ResourcesInverseIndicesLists, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsLists, - ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, - EntryIndicesLists, - EntryReshapeIndicesLists, - >, + Registry: registry::Registry, + T: Sealed<'a, Registry, Resources, Indices>, { } @@ -312,10 +144,7 @@ doc::non_root_macro! { /// Result, /// Views, /// }, - /// registry::{ - /// ContainsParQuery, - /// ContainsQuery, - /// }, + /// registry, /// system::{ /// schedule, /// schedule::task, @@ -323,6 +152,7 @@ doc::non_root_macro! { /// System, /// }, /// }; + /// use rayon::iter::ParallelIterator; /// /// // Define components. /// struct Foo(usize); @@ -337,11 +167,12 @@ doc::non_root_macro! { /// type ResourceViews<'a> = Views!(); /// type EntryViews<'a> = Views!(); /// - /// fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + /// fn run<'a, R, S, I, E>( /// &mut self, - /// query_results: Result, VI, P, I, Q>, Self::ResourceViews<'a>, Self::EntryViews<'a>, (EP, EI, EQ)>, + /// query_results: Result, Self::EntryViews<'a>, E>, /// ) where - /// R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + /// R: registry::Registry, + /// I: Iterator>, /// { /// // Do something.. /// } @@ -355,11 +186,12 @@ doc::non_root_macro! { /// type ResourceViews<'a> = Views!(); /// type EntryViews<'a> = Views!(); /// - /// fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + /// fn run<'a, R, S, I, E>( /// &mut self, - /// query_results: Result, VI, P, I, Q>, Self::ResourceViews<'a>, Self::EntryViews<'a>, (EP, EI, EQ)>, + /// query_results: Result, Self::EntryViews<'a>, E>, /// ) where - /// R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + /// R: registry::Registry, + /// I: ParallelIterator>, /// { /// // Do something.. /// } @@ -399,10 +231,7 @@ pub(crate) mod inner { /// Result, /// Views, /// }, - /// registry::{ - /// ContainsParQuery, - /// ContainsQuery, - /// }, + /// registry, /// system::{ /// schedule::task, /// ParSystem, @@ -410,6 +239,7 @@ pub(crate) mod inner { /// System, /// }, /// }; + /// use rayon::iter::ParallelIterator; /// /// // Define components. /// struct Foo(usize); @@ -424,11 +254,12 @@ pub(crate) mod inner { /// type ResourceViews<'a> = Views!(); /// type EntryViews<'a> = Views!(); /// - /// fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + /// fn run<'a, R, S, I, E>( /// &mut self, - /// query_results: Result, VI, P, I, Q>, Self::ResourceViews<'a>, Self::EntryViews<'a>, (EP, EI, EQ)>, + /// query_results: Result, Self::EntryViews<'a>, E>, /// ) where - /// R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + /// R: registry::Registry, + /// I: Iterator>, /// { /// // Do something.. /// } @@ -442,11 +273,12 @@ pub(crate) mod inner { /// type ResourceViews<'a> = Views!(); /// type EntryViews<'a> = Views!(); /// - /// fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + /// fn run<'a, R, S, I, E>( /// &mut self, - /// query_results: Result, VI, P, I, Q>, Self::ResourceViews<'a>, Self::EntryViews<'a>, (EP, EI, EQ)>, + /// query_results: Result, Self::EntryViews<'a>, E>, /// ) where - /// R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + /// R: registry::Registry, + /// I: ParallelIterator>, /// { /// // Do something.. /// } @@ -474,14 +306,10 @@ mod tests { entity, query::{ filter, - result, Result, Views, }, - registry::{ - ContainsParQuery, - ContainsQuery, - }, + registry, system::{ schedule::{ stage, @@ -495,6 +323,7 @@ mod tests { Resources, }; use core::any::TypeId; + use rayon::iter::ParallelIterator; struct A; struct B; @@ -507,40 +336,7 @@ mod tests { #[test] fn null() { assert_eq!( - TypeId::of::< - >::Stages, - >(), + TypeId::of::<>::Stages>(), TypeId::of::() ); } @@ -549,38 +345,7 @@ mod tests { fn null_resources() { assert_eq!( TypeId::of::< - >::Stages, + >::Stages, >(), TypeId::of::() ); @@ -590,38 +355,7 @@ mod tests { fn null_components_and_resources() { assert_eq!( TypeId::of::< - >::Stages, + >::Stages, >(), TypeId::of::() ); @@ -637,20 +371,15 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { - unreachable!() + unimplemented!() } } @@ -660,33 +389,7 @@ mod tests { '_, Registry, Resources!(), - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, + _ >>::Stages, >(), TypeId::of::<((&mut task::System, stage::Null), stages::Null)>() @@ -703,20 +406,15 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { - unreachable!() + unimplemented!() } } @@ -726,33 +424,7 @@ mod tests { '_, Registry, Resources!(), - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, + _ >>::Stages, >(), TypeId::of::<((&mut task::System, stage::Null), stages::Null)>() @@ -769,20 +441,15 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { - unreachable!() + unimplemented!() } } @@ -793,32 +460,6 @@ mod tests { Registry, Resources!(), _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, >>::Stages, >(), TypeId::of::<((&mut task::System, stage::Null), stages::Null)>() @@ -835,20 +476,15 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { - unreachable!() + unimplemented!() } } @@ -859,32 +495,6 @@ mod tests { Registry, Resources!(), _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, >>::Stages, >(), TypeId::of::<((&mut task::System, stage::Null), stages::Null)>() @@ -901,20 +511,15 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { - unreachable!() + unimplemented!() } } @@ -925,32 +530,6 @@ mod tests { Registry, Resources!(), _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, >>::Stages, >(), TypeId::of::<( @@ -970,20 +549,15 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { - unreachable!() + unimplemented!() } } @@ -994,32 +568,6 @@ mod tests { Registry, Resources!(), _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, >>::Stages, >(), TypeId::of::<((&mut task::ParSystem, stage::Null), stages::Null)>() @@ -1036,20 +584,15 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { - unreachable!() + unimplemented!() } } @@ -1059,33 +602,7 @@ mod tests { '_, Registry, Resources!(), - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, + _ >>::Stages, >(), TypeId::of::<((&mut task::ParSystem, stage::Null), stages::Null)>() @@ -1102,20 +619,15 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { - unreachable!() + unimplemented!() } } @@ -1126,32 +638,6 @@ mod tests { Registry, Resources!(), _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, >>::Stages, >(), TypeId::of::<( @@ -1171,55 +657,24 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, - ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - { - unreachable!() - } - } - - assert_eq!( - TypeId::of::< - <(task::ParSystem, task::Null) as Schedule< - '_, - Registry, - Resources!(), - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, + _query_results: Result, Self::EntryViews<'a>, E>, + ) where + R: registry::Registry, + I: ParallelIterator>, + { + unimplemented!() + } + } + + assert_eq!( + TypeId::of::< + <(task::ParSystem, task::Null) as Schedule< + '_, + Registry, + Resources!(), _, >>::Stages, >(), @@ -1240,20 +695,15 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { - unreachable!() + unimplemented!() } } @@ -1264,32 +714,6 @@ mod tests { Registry, Resources!(), _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, >>::Stages, >(), TypeId::of::<( @@ -1309,18 +733,13 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { unimplemented!() } @@ -1334,18 +753,13 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { unimplemented!() } @@ -1359,18 +773,13 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { unimplemented!() } @@ -1381,38 +790,7 @@ mod tests { <( task::System, (task::System, (task::System, task::Null)) - ) as Schedule< - '_, - Registry, - Resources!(), - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - >>::Stages, + ) as Schedule<'_, Registry, Resources!(), _>>::Stages, >(), TypeId::of::<( (&mut task::System, (&mut task::System, stage::Null)), @@ -1431,18 +809,13 @@ mod tests { type ResourceViews<'a> = Views!(&'a A); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { unimplemented!() } @@ -1456,18 +829,13 @@ mod tests { type ResourceViews<'a> = Views!(&'a A, &'a B); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { unimplemented!() } @@ -1480,32 +848,6 @@ mod tests { Registry!(), Resources!(A, B), _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, >>::Stages, >(), TypeId::of::<( @@ -1528,18 +870,13 @@ mod tests { type ResourceViews<'a> = Views!(&'a mut A); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { unimplemented!() } @@ -1553,18 +890,13 @@ mod tests { type ResourceViews<'a> = Views!(&'a mut A, &'a B); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { unimplemented!() } @@ -1578,18 +910,13 @@ mod tests { type ResourceViews<'a> = Views!(&'a mut B, &'a C); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { unimplemented!() } @@ -1600,38 +927,7 @@ mod tests { <( task::System, (task::ParSystem, (task::System, task::Null)) - ) as Schedule< - '_, - Registry!(), - Resources!(A, B, C), - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - >>::Stages, + ) as Schedule<'_, Registry!(), Resources!(A, B, C), _>>::Stages, >(), TypeId::of::<( (&mut task::System, stage::Null), @@ -1653,18 +949,13 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(&'a A); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { unimplemented!() } @@ -1678,18 +969,13 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(&'a A, &'a B); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { unimplemented!() } @@ -1702,32 +988,6 @@ mod tests { Registry, Resources!(), _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, >>::Stages, >(), TypeId::of::<( @@ -1750,18 +1010,13 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(&'a A); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { unimplemented!() } @@ -1775,18 +1030,13 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(&'a mut A, &'a B); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { unimplemented!() } @@ -1799,32 +1049,6 @@ mod tests { Registry, Resources!(), _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, >>::Stages, >(), TypeId::of::<( @@ -1844,18 +1068,13 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(&'a A); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { unimplemented!() } @@ -1869,18 +1088,13 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(&'a A, &'a C); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { unimplemented!() } @@ -1893,32 +1107,6 @@ mod tests { Registry, Resources!(), _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, >>::Stages, >(), TypeId::of::<( @@ -1941,18 +1129,13 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(&'a A); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { unimplemented!() } @@ -1966,18 +1149,13 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(&'a A, &'a B); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { unimplemented!() } @@ -1990,32 +1168,6 @@ mod tests { Registry, Resources!(), _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, - _, >>::Stages, >(), TypeId::of::<( @@ -2024,4 +1176,41 @@ mod tests { )>() ); } + + /// This test verifies that the schedule compiles just fine even when the registry contains a + /// non-`Sync` component, so long as the schedule itself doesn't borrow said component. + #[test] + fn registry_contains_non_sync_component() { + struct Foo; + + impl System for Foo { + type Views<'a> = Views!(); + type Filter = filter::None; + type ResourceViews<'a> = Views!(); + type EntryViews<'a> = Views!(); + + #[cfg_attr(coverage_nightly, no_coverage)] + fn run<'a, R, S, I, E>( + &mut self, + _query_results: Result, Self::EntryViews<'a>, E>, + ) where + R: registry::Registry, + I: Iterator>, + { + unimplemented!() + } + } + + assert_eq!( + TypeId::of::< + <(task::System, task::Null) as Schedule< + '_, + (alloc::rc::Rc, Registry), + Resources!(), + _, + >>::Stages, + >(), + TypeId::of::<((&mut task::System, stage::Null), stages::Null)>() + ); + } } diff --git a/src/system/schedule/scheduler.rs b/src/system/schedule/scheduler.rs index 9801af10..cde547da 100644 --- a/src/system/schedule/scheduler.rs +++ b/src/system/schedule/scheduler.rs @@ -23,26 +23,10 @@ pub trait Scheduler< ResourcesIndicesLists, ResourcesContainmentsLists, ResourcesInverseIndicesLists, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsLists, + QueryIndicesLists, ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, + DisjointIndicesLists, EntryIndicesLists, - EntryReshapeIndicesLists, > where R: Registry, { @@ -50,26 +34,10 @@ pub trait Scheduler< 'a, R, Resources, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsLists, + QueryIndicesLists, ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, + DisjointIndicesLists, EntryIndicesLists, - EntryReshapeIndicesLists, >; fn as_stages(&'a mut self) -> Self::Stages; @@ -83,22 +51,6 @@ impl<'a, R, Resources> Null, Null, Null, - Null, - Null, - Null, - Null, - stages::Null, - stages::Null, - stages::Null, - stages::Null, - stages::Null, - stages::Null, - stages::Null, - stages::Null, - stages::Null, - stages::Null, - stages::Null, - stages::Null, stages::Null, stages::Null, stages::Null, @@ -139,46 +91,14 @@ impl< ResourcesContainmentsLists, ResourcesInverseIndicesList, ResourcesInverseIndicesLists, - SFI, - SFIS, - SVI, - SVIS, - SP, - SPS, - SI, - SIS, - SQ, - SQS, - ResourceViewsContainmentsList, - ResourceViewsContainmentsLists, + QueryIndicesList, + QueryIndicesLists, ResourceViewsIndicesList, ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsList, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesList, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsList, - EntryViewsContainmentsLists, - EntryViewsIndicesList, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesList, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesList, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesList, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesList, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsList, - EntryContainmentsLists, + DisjointIndicesList, + DisjointIndicesLists, EntryIndicesList, EntryIndicesLists, - EntryReshapeIndicesList, - EntryReshapeIndicesLists, > Scheduler< 'a, @@ -191,47 +111,10 @@ impl< (ResourcesIndicesList, ResourcesIndicesLists), (ResourcesContainmentsList, ResourcesContainmentsLists), (ResourcesInverseIndicesList, ResourcesInverseIndicesLists), - (SFI, SFIS), - (SVI, SVIS), - (SP, SPS), - (SI, SIS), - (SQ, SQS), - ( - ResourceViewsContainmentsList, - ResourceViewsContainmentsLists, - ), + (QueryIndicesList, QueryIndicesLists), (ResourceViewsIndicesList, ResourceViewsIndicesLists), - ( - ResourceViewsCanonicalContainmentsList, - ResourceViewsCanonicalContainmentsLists, - ), - ( - ResourceViewsReshapeIndicesList, - ResourceViewsReshapeIndicesLists, - ), - (EntryViewsContainmentsList, EntryViewsContainmentsLists), - (EntryViewsIndicesList, EntryViewsIndicesLists), - (EntryViewsReshapeIndicesList, EntryViewsReshapeIndicesLists), - (EntryViewsInverseIndicesList, EntryViewsInverseIndicesLists), - ( - EntryViewsOppositeContainmentsList, - EntryViewsOppositeContainmentsLists, - ), - ( - EntryViewsOppositeIndicesList, - EntryViewsOppositeIndicesLists, - ), - ( - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeReshapeIndicesLists, - ), - ( - EntryViewsOppositeInverseIndicesList, - EntryViewsOppositeInverseIndicesLists, - ), - (EntryContainmentsList, EntryContainmentsLists), + (DisjointIndicesList, DisjointIndicesLists), (EntryIndicesList, EntryIndicesLists), - (EntryReshapeIndicesList, EntryReshapeIndicesLists), > for (T, U) where (T, U): Stager< @@ -247,26 +130,10 @@ where ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >, <(T, U) as Stager< 'a, @@ -281,26 +148,10 @@ where ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >>::Remainder: Scheduler< 'a, R, @@ -312,26 +163,10 @@ where ResourcesIndicesLists, ResourcesContainmentsLists, ResourcesInverseIndicesLists, - SFIS, - SVIS, - SPS, - SIS, - SQS, - ResourceViewsContainmentsLists, + QueryIndicesLists, ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, + DisjointIndicesLists, EntryIndicesLists, - EntryReshapeIndicesLists, >, R: Registry + 'a, Resources: 'a, @@ -342,26 +177,10 @@ where ResourcesIndicesList: 'a, ResourcesContainmentsList: 'a, ResourcesInverseIndicesList: 'a, - SFI: 'a, - SVI: 'a, - SP: 'a, - SI: 'a, - SQ: 'a, - ResourceViewsContainmentsList: 'a, + QueryIndicesList: 'a, ResourceViewsIndicesList: 'a, - ResourceViewsCanonicalContainmentsList: 'a, - ResourceViewsReshapeIndicesList: 'a, - EntryViewsContainmentsList: 'a, - EntryViewsIndicesList: 'a, - EntryViewsReshapeIndicesList: 'a, - EntryViewsInverseIndicesList: 'a, - EntryViewsOppositeContainmentsList: 'a, - EntryViewsOppositeIndicesList: 'a, - EntryViewsOppositeReshapeIndicesList: 'a, - EntryViewsOppositeInverseIndicesList: 'a, - EntryContainmentsList: 'a, + DisjointIndicesList: 'a, EntryIndicesList: 'a, - EntryReshapeIndicesList: 'a, { type Stages = ( <(T, U) as Stager< @@ -377,26 +196,10 @@ where ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >>::Stage, <<(T, U) as Stager< 'a, @@ -411,26 +214,10 @@ where ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >>::Remainder as Scheduler< 'a, R, @@ -442,26 +229,10 @@ where ResourcesIndicesLists, ResourcesContainmentsLists, ResourcesInverseIndicesLists, - SFIS, - SVIS, - SPS, - SIS, - SQS, - ResourceViewsContainmentsLists, + QueryIndicesLists, ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, + DisjointIndicesLists, EntryIndicesLists, - EntryReshapeIndicesLists, >>::Stages, ); diff --git a/src/system/schedule/sealed.rs b/src/system/schedule/sealed.rs index 44de9e88..bb958ce0 100644 --- a/src/system/schedule/sealed.rs +++ b/src/system/schedule/sealed.rs @@ -6,64 +6,22 @@ use crate::{ }, }; -pub trait Sealed< - 'a, - R, - Resources, - I, - P, - RI, - MergeParametersList, - ResourcesIndicesLists, - ResourcesContainmentsLists, - ResourcesInverseIndicesLists, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsLists, - ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, - EntryIndicesLists, - EntryReshapeIndicesLists, -> where +pub trait Sealed<'a, R, Resources, Indices> +where R: Registry, { + type QueryIndicesLists; + type ResourceViewsIndicesLists; + type DisjointIndicesLists; + type EntryIndicesLists; type Stages: Stages< 'a, R, Resources, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsLists, - ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, - EntryIndicesLists, - EntryReshapeIndicesLists, + Self::QueryIndicesLists, + Self::ResourceViewsIndicesLists, + Self::DisjointIndicesLists, + Self::EntryIndicesLists, >; fn as_stages(&'a mut self) -> Self::Stages; @@ -81,58 +39,28 @@ impl< ResourcesIndicesLists, ResourcesContainmentsLists, ResourcesInverseIndicesLists, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsLists, + QueryIndicesLists, ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, + DisjointIndicesLists, EntryIndicesLists, - EntryReshapeIndicesLists, > Sealed< 'a, R, Resources, - I, - P, - RI, - MergeParametersList, - ResourcesIndicesLists, - ResourcesContainmentsLists, - ResourcesInverseIndicesLists, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsLists, - ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, - EntryIndicesLists, - EntryReshapeIndicesLists, + ( + I, + P, + RI, + MergeParametersList, + ResourcesIndicesLists, + ResourcesContainmentsLists, + ResourcesInverseIndicesLists, + QueryIndicesLists, + ResourceViewsIndicesLists, + DisjointIndicesLists, + EntryIndicesLists, + ), > for T where R: Registry, @@ -147,28 +75,16 @@ where ResourcesIndicesLists, ResourcesContainmentsLists, ResourcesInverseIndicesLists, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsLists, + QueryIndicesLists, ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, + DisjointIndicesLists, EntryIndicesLists, - EntryReshapeIndicesLists, >, { + type QueryIndicesLists = QueryIndicesLists; + type ResourceViewsIndicesLists = ResourceViewsIndicesLists; + type DisjointIndicesLists = DisjointIndicesLists; + type EntryIndicesLists = EntryIndicesLists; type Stages = >::Stages; #[inline] diff --git a/src/system/schedule/stage.rs b/src/system/schedule/stage.rs index e9b4605b..29550d83 100644 --- a/src/system/schedule/stage.rs +++ b/src/system/schedule/stage.rs @@ -31,26 +31,10 @@ pub trait Stage< 'a, R, Resources, - FI, - VI, - P, - I, - Q, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >: Send where R: Registry, { @@ -65,26 +49,10 @@ pub trait Stage< fn run< 'b, N, - NFI, - NVI, - NP, - NI, - NQ, - NextResourceViewsContainmentsLists, + NextQueryIndicesLists, NextResourceViewsIndicesLists, - NextResourceViewsCanonicalContainmentsLists, - NextResourceViewsReshapeIndicesLists, - NextEntryViewsContainmentsList, - NextEntryViewsIndicesList, - NextEntryViewsReshapeIndicesList, - NextEntryViewsInverseIndicesList, - NextEntryViewsOppositeContainmentsList, - NextEntryViewsOppositeIndicesList, - NextEntryViewsOppositeReshapeIndicesList, - NextEntryViewsOppositeInverseIndicesList, - NextEntryContainmentsList, + NextDisjointIndicesList, NextEntryIndicesList, - NextEntryReshapeIndicesList, >( &mut self, world: SendableWorld, @@ -97,26 +65,10 @@ pub trait Stage< 'b, R, Resources, - NFI, - NVI, - NP, - NI, - NQ, - NextResourceViewsContainmentsLists, + NextQueryIndicesLists, NextResourceViewsIndicesLists, - NextResourceViewsCanonicalContainmentsLists, - NextResourceViewsReshapeIndicesLists, - NextEntryViewsContainmentsList, - NextEntryViewsIndicesList, - NextEntryViewsReshapeIndicesList, - NextEntryViewsInverseIndicesList, - NextEntryViewsOppositeContainmentsList, - NextEntryViewsOppositeIndicesList, - NextEntryViewsOppositeReshapeIndicesList, - NextEntryViewsOppositeInverseIndicesList, - NextEntryContainmentsList, + NextDisjointIndicesList, NextEntryIndicesList, - NextEntryReshapeIndicesList, >; /// Attempt to run as many tasks within this stage as possible as add-ons to the previous @@ -140,32 +92,7 @@ pub trait Stage< fn new_has_run() -> Self::HasRun; } -impl - Stage< - '_, - R, - Resources, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - > for Null +impl Stage<'_, R, Resources, Null, Null, Null, Null> for Null where R: Registry, { @@ -174,26 +101,10 @@ where fn run< 'b, N, - NFI, - NVI, - NP, - NI, - NQ, - NextResourceViewsContainmentsLists, + NextQueryIndicesLists, NextResourceViewsIndicesLists, - NextResourceViewsCanonicalContainmentsLists, - NextResourceViewsReshapeIndicesLists, - NextEntryViewsContainmentsList, - NextEntryViewsIndicesList, - NextEntryViewsReshapeIndicesList, - NextEntryViewsInverseIndicesList, - NextEntryViewsOppositeContainmentsList, - NextEntryViewsOppositeIndicesList, - NextEntryViewsOppositeReshapeIndicesList, - NextEntryViewsOppositeInverseIndicesList, - NextEntryContainmentsList, + NextDisjointIndicesList, NextEntryIndicesList, - NextEntryReshapeIndicesList, >( &mut self, world: SendableWorld, @@ -206,26 +117,10 @@ where 'b, R, Resources, - NFI, - NVI, - NP, - NI, - NQ, - NextResourceViewsContainmentsLists, + NextQueryIndicesLists, NextResourceViewsIndicesLists, - NextResourceViewsCanonicalContainmentsLists, - NextResourceViewsReshapeIndicesLists, - NextEntryViewsContainmentsList, - NextEntryViewsIndicesList, - NextEntryViewsReshapeIndicesList, - NextEntryViewsInverseIndicesList, - NextEntryViewsOppositeContainmentsList, - NextEntryViewsOppositeIndicesList, - NextEntryViewsOppositeReshapeIndicesList, - NextEntryViewsOppositeInverseIndicesList, - NextEntryContainmentsList, + NextDisjointIndicesList, NextEntryIndicesList, - NextEntryReshapeIndicesList, >, { // Check if borrowed_archetypes is empty. @@ -258,58 +153,18 @@ fn query_archetype_identifiers< R, Resources, T, - FI, - VI, - P, - I, - Q, - ResourceViewsContainments, + QueryIndices, ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, + DisjointIndices, EntryIndices, - EntryReshapeIndices, >( world: SendableWorld, borrowed_archetypes: &mut HashMap, R::Claims, FnvBuildHasher>, ) -> bool where - R: ContainsQuery<'a, T::Filter, FI, T::Views, VI, P, I, Q>, + R: ContainsQuery<'a, T::Filter, T::Views, QueryIndices>, Resources: 'a, - T: Task< - 'a, - R, - Resources, - FI, - VI, - P, - I, - Q, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, - EntryIndices, - EntryReshapeIndices, - >, + T: Task<'a, R, Resources, QueryIndices, ResourceViewsIndices, DisjointIndices, EntryIndices>, { let mut merged_borrowed_archetypes = borrowed_archetypes.clone(); @@ -343,57 +198,17 @@ fn query_archetype_identifiers_unchecked< R, Resources, T, - FI, - VI, - P, - I, - Q, - ResourceViewsContainments, + QueryIndices, ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, + DisjointIndices, EntryIndices, - EntryReshapeIndices, >( world: SendableWorld, borrowed_archetypes: &mut HashMap, R::Claims, FnvBuildHasher>, ) where - R: ContainsQuery<'a, T::Filter, FI, T::Views, VI, P, I, Q>, + R: ContainsQuery<'a, T::Filter, T::Views, QueryIndices>, Resources: 'a, - T: Task< - 'a, - R, - Resources, - FI, - VI, - P, - I, - Q, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, - EntryIndices, - EntryReshapeIndices, - >, + T: Task<'a, R, Resources, QueryIndices, ResourceViewsIndices, DisjointIndices, EntryIndices>, { for (identifier, claims) in // SAFETY: The access to the world's archetype identifiers follows Rust's borrowing @@ -412,136 +227,37 @@ impl< Resources, T, U, - FI, - FIS, - VI, - VIS, - P, - PS, - I, - IS, - Q, - QS, - ResourceViewsContainments, - ResourceViewsContainmentsList, + QueryIndices, + QueryIndicesList, ResourceViewsIndices, ResourceViewsIndicesList, - ResourceViewsCanonicalContainments, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndices, - ResourceViewsReshapeIndicesList, - EntryViewsContainments, - EntryViewsContainmentsList, - EntryViewsIndices, - EntryViewsIndicesList, - EntryViewsReshapeIndices, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndices, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainments, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndices, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndices, - EntryViewsOppositeInverseIndicesList, - EntryContainments, - EntryContainmentsList, + DisjointIndices, + DisjointIndicesList, EntryIndices, EntryIndicesList, - EntryReshapeIndices, - EntryReshapeIndicesList, > Stage< 'a, R, Resources, - (FI, FIS), - (VI, VIS), - (P, PS), - (I, IS), - (Q, QS), - (ResourceViewsContainments, ResourceViewsContainmentsList), + (QueryIndices, QueryIndicesList), (ResourceViewsIndices, ResourceViewsIndicesList), - ( - ResourceViewsCanonicalContainments, - ResourceViewsCanonicalContainmentsList, - ), - (ResourceViewsReshapeIndices, ResourceViewsReshapeIndicesList), - (EntryViewsContainments, EntryViewsContainmentsList), - (EntryViewsIndices, EntryViewsIndicesList), - (EntryViewsReshapeIndices, EntryViewsReshapeIndicesList), - (EntryViewsInverseIndices, EntryViewsInverseIndicesList), - ( - EntryViewsOppositeContainments, - EntryViewsOppositeContainmentsList, - ), - (EntryViewsOppositeIndices, EntryViewsOppositeIndicesList), - ( - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeReshapeIndicesList, - ), - ( - EntryViewsOppositeInverseIndices, - EntryViewsOppositeInverseIndicesList, - ), - (EntryContainments, EntryContainmentsList), + (DisjointIndices, DisjointIndicesList), (EntryIndices, EntryIndicesList), - (EntryReshapeIndices, EntryReshapeIndicesList), > for (&mut T, U) where - R: ContainsQuery<'a, T::Filter, FI, T::Views, VI, P, I, Q>, + R: ContainsQuery<'a, T::Filter, T::Views, QueryIndices>, Resources: 'a, - T: Task< - 'a, - R, - Resources, - FI, - VI, - P, - I, - Q, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, - EntryIndices, - EntryReshapeIndices, - > + Send, + T: Task<'a, R, Resources, QueryIndices, ResourceViewsIndices, DisjointIndices, EntryIndices> + + Send, U: Stage< 'a, R, Resources, - FIS, - VIS, - PS, - IS, - QS, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >, { type HasRun = (bool, U::HasRun); @@ -549,26 +265,10 @@ where fn run< 'b, N, - NFI, - NVI, - NP, - NI, - NQ, - NextResourceViewsContainmentsLists, + NextQueryIndicesLists, NextResourceViewsIndicesLists, - NextResourceViewsCanonicalContainmentsLists, - NextResourceViewsReshapeIndicesLists, - NextEntryViewsContainmentsList, - NextEntryViewsIndicesList, - NextEntryViewsReshapeIndicesList, - NextEntryViewsInverseIndicesList, - NextEntryViewsOppositeContainmentsList, - NextEntryViewsOppositeIndicesList, - NextEntryViewsOppositeReshapeIndicesList, - NextEntryViewsOppositeInverseIndicesList, - NextEntryContainments, + NextDisjointIndicesList, NextEntryIndices, - NextEntryReshapeIndices, >( &mut self, world: SendableWorld, @@ -581,26 +281,10 @@ where 'b, R, Resources, - NFI, - NVI, - NP, - NI, - NQ, - NextResourceViewsContainmentsLists, + NextQueryIndicesLists, NextResourceViewsIndicesLists, - NextResourceViewsCanonicalContainmentsLists, - NextResourceViewsReshapeIndicesLists, - NextEntryViewsContainmentsList, - NextEntryViewsIndicesList, - NextEntryViewsReshapeIndicesList, - NextEntryViewsInverseIndicesList, - NextEntryViewsOppositeContainmentsList, - NextEntryViewsOppositeIndicesList, - NextEntryViewsOppositeReshapeIndicesList, - NextEntryViewsOppositeInverseIndicesList, - NextEntryContainments, + NextDisjointIndicesList, NextEntryIndices, - NextEntryReshapeIndices, >, { // Determine whether this task still needs to run, or if it has been run as part of a @@ -618,26 +302,10 @@ where R, Resources, T, - FI, - VI, - P, - I, - Q, - ResourceViewsContainments, + QueryIndices, ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, + DisjointIndices, EntryIndices, - EntryReshapeIndices, >(world, &mut borrowed_archetypes); self.1 @@ -659,26 +327,10 @@ where R, Resources, T, - FI, - VI, - P, - I, - Q, - ResourceViewsContainments, + QueryIndices, ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, + DisjointIndices, EntryIndices, - EntryReshapeIndices, >(world, &mut borrowed_archetypes) { rayon::join( diff --git a/src/system/schedule/stager.rs b/src/system/schedule/stager.rs index 93d7daeb..53b09884 100644 --- a/src/system/schedule/stager.rs +++ b/src/system/schedule/stager.rs @@ -41,26 +41,10 @@ pub trait Stager< ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, > where R: Registry, { @@ -68,26 +52,10 @@ pub trait Stager< 'a, R, Resources, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >; type Remainder; @@ -112,22 +80,6 @@ impl<'a, R, Resources, C, ResourcesClaims> stage::Null, stage::Null, stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, > for task::Null where R: Registry, @@ -154,7 +106,7 @@ impl< PS, RI, RIS, - P0, P1, I0, I1, Q0, Q1, MergeContainments, MergeParameters, + LeftMergeIndices, RightMergeIndices, MergeContainments, MergeParameters, ResourcesClaims, ResourcesIndices, ResourcesIndicesList, @@ -162,26 +114,10 @@ impl< ResourcesContainmentsList, ResourcesInverseIndices, ResourcesInverseIndicesList, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, > Stager< 'a, @@ -191,40 +127,111 @@ impl< (I, IS), (P, PS), (RI, RIS), - ((P0, P1, I0, I1, Q0, Q1, MergeContainments), MergeParameters), + ((LeftMergeIndices, RightMergeIndices, MergeContainments), MergeParameters), ResourcesClaims, (ResourcesIndices, ResourcesIndicesList), (ResourcesContainments, ResourcesContainmentsList), (ResourcesInverseIndices, ResourcesInverseIndicesList), - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, > for (task::System, U) where T::EntryViews<'a>: view::Views<'a>, - R: ContainsViewsSealed<'a, T::Views<'a>, P0, I0, Q0> + ContainsViewsSealed<'a, T::EntryViews<'a>, P1, I1, Q1>, - , P0, I0, Q0>>::Viewable: view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>, - , P0, I0, Q0>>::Viewable: ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>, - , P1, I1, Q1>>::Viewable: ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>, + R: ContainsViewsSealed< + 'a, + T::Views<'a>, + LeftMergeIndices + > + ContainsViewsSealed< + 'a, + T::EntryViews<'a>, + RightMergeIndices + >, + , LeftMergeIndices>>::Viewable: view::Merge< + <, + LeftMergeIndices + >>::Viewable as ContainsViewsOuter< + 'a, + T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices, + >>::Canonical, + <, + RightMergeIndices + >>::Viewable as ContainsViewsOuter< + 'a, + T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices, + >>::Canonical, + MergeContainments + >, + , + LeftMergeIndices + >>::Viewable: ContainsViewsOuter< + 'a, + T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices, + >, + , + RightMergeIndices + >>::Viewable: ContainsViewsOuter< + 'a, + T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices, + >, T: System + Send, - C: Claims<'a, <, P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>, + C: Claims< + 'a, + <, + LeftMergeIndices + >>::Viewable as view::Merge< + <, + LeftMergeIndices + >>::Viewable as ContainsViewsOuter< + 'a, + T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices, + >>::Canonical, + <, + RightMergeIndices, + >>::Viewable as ContainsViewsOuter< + 'a, + T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices, + >>::Canonical, + MergeContainments, + >>::Merged, + I, + P, + R, + RI, + >, ResourcesClaims: Claims< 'a, T::ResourceViews<'a>, @@ -234,7 +241,7 @@ where ResourcesInverseIndices, >, ( - , P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, + , LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, , LeftMergeIndices>>::Containments, , LeftMergeIndices>>::Indices, , LeftMergeIndices>>::ReshapeIndices>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, , RightMergeIndices>>::Containments, , RightMergeIndices>>::Indices, , RightMergeIndices>>::ReshapeIndices>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, , @@ -249,7 +256,13 @@ where R, Resources, <( - , P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, + , LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, , @@ -259,7 +272,13 @@ where ResourcesInverseIndices, >>::Decision, ) as Merger>::Decision, - (<, P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, C), + (<, LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>>::Merged, C), IS, PS, RIS, @@ -268,26 +287,10 @@ where ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >, { type Stage = <(task::System, U) as Cutoff< @@ -295,7 +298,13 @@ where R, Resources, <( - , P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, + , LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, , @@ -305,7 +314,13 @@ where ResourcesInverseIndices, >>::Decision, ) as Merger>::Decision, - (<, P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, C), + (<, LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>>::Merged, C), IS, PS, RIS, @@ -314,33 +329,23 @@ where ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >>::Stage; type Remainder = <(task::System, U) as Cutoff< 'a, R, Resources, <( - , P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, + , LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, , @@ -350,7 +355,13 @@ where ResourcesInverseIndices, >>::Decision, ) as Merger>::Decision, - (<, P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, C), + (<, LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>>::Merged, C), IS, PS, RIS, @@ -359,26 +370,10 @@ where ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >>::Remainder; #[inline] @@ -400,7 +395,7 @@ impl< PS, RI, RIS, - P0, P1, I0, I1, Q0, Q1, MergeContainments, MergeParameters, + LeftMergeIndices, RightMergeIndices, MergeContainments, MergeParameters, ResourcesClaims, ResourcesIndices, ResourcesIndicesList, @@ -408,26 +403,10 @@ impl< ResourcesContainmentsList, ResourcesInverseIndices, ResourcesInverseIndicesList, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, > Stager< 'a, @@ -437,40 +416,42 @@ impl< (I, IS), (P, PS), (RI, RIS), - ((P0, P1, I0, I1, Q0, Q1, MergeContainments), MergeParameters), + ((LeftMergeIndices, RightMergeIndices, MergeContainments), MergeParameters), ResourcesClaims, (ResourcesIndices, ResourcesIndicesList), (ResourcesContainments, ResourcesContainmentsList), (ResourcesInverseIndices, ResourcesInverseIndicesList), - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, > for (task::ParSystem, U) where T::EntryViews<'a>: view::Views<'a>, - R: ContainsViewsSealed<'a, T::Views<'a>, P0, I0, Q0> + ContainsViewsSealed<'a, T::EntryViews<'a>, P1, I1, Q1>, - , P0, I0, Q0>>::Viewable: view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>, - , P0, I0, Q0>>::Viewable: ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>, - , P1, I1, Q1>>::Viewable: ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>, + R: ContainsViewsSealed<'a, T::Views<'a>, LeftMergeIndices> + ContainsViewsSealed<'a, T::EntryViews<'a>, RightMergeIndices>, + , LeftMergeIndices>>::Viewable: view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>, + , LeftMergeIndices>>::Viewable: ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>, + , RightMergeIndices>>::Viewable: ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>, T: ParSystem + Send, - C: Claims<'a, <, P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>, + C: Claims<'a, <, LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>, ResourcesClaims: Claims< 'a, T::ResourceViews<'a>, @@ -480,7 +461,13 @@ where ResourcesInverseIndices, >, ( - , P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, + , LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, , @@ -495,7 +482,13 @@ where R, Resources, <( - , P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, + , LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, , @@ -505,7 +498,13 @@ where ResourcesInverseIndices, >>::Decision, ) as Merger>::Decision, - (<, P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, C), + (<, LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>>::Merged, C), IS, PS, RIS, @@ -514,26 +513,10 @@ where ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >, { type Stage = <(task::ParSystem, U) as Cutoff< @@ -541,7 +524,13 @@ where R, Resources, <( - , P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, + , LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, , @@ -551,7 +540,13 @@ where ResourcesInverseIndices, >>::Decision, ) as Merger>::Decision, - (<, P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, C), + (<, LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>>::Merged, C), IS, PS, RIS, @@ -560,33 +555,23 @@ where ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >>::Stage; type Remainder = <(task::ParSystem, U) as Cutoff< 'a, R, Resources, <( - , P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, + , LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>>::Merged, I, P, R, RI>>::Decision, , @@ -596,7 +581,13 @@ where ResourcesInverseIndices, >>::Decision, ) as Merger>::Decision, - (<, P0, I0, Q0>>::Viewable as view::Merge<<, P0, I0, Q0>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, P0, I0, Q0>>::Canonical, <, P1, I1, Q1>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, P1, I1, Q1>>::Canonical, MergeContainments>>::Merged, C), + (<, LeftMergeIndices>>::Viewable as view::Merge<<, LeftMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::Views<'a>, + , LeftMergeIndices>>::Containments, + , LeftMergeIndices>>::Indices, + , LeftMergeIndices>>::ReshapeIndices,>>::Canonical, <, RightMergeIndices>>::Viewable as ContainsViewsOuter<'a, T::EntryViews<'a>, + , RightMergeIndices>>::Containments, + , RightMergeIndices>>::Indices, + , RightMergeIndices>>::ReshapeIndices,>>::Canonical, MergeContainments>>::Merged, C), IS, PS, RIS, @@ -605,26 +596,10 @@ where ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >>::Remainder; #[inline] @@ -647,26 +622,10 @@ pub trait Cutoff< ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, > where R: Registry, { @@ -674,26 +633,10 @@ pub trait Cutoff< 'a, R, Resources, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >; type Remainder; @@ -719,22 +662,6 @@ impl<'a, R, Resources, T, C, ResourcesClaims> stage::Null, stage::Null, stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, - stage::Null, > for T where R: Registry, @@ -764,46 +691,14 @@ impl< ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFI, - SFIS, - SVI, - SVIS, - SP, - SPS, - SI, - SIS, - SQ, - SQS, - ResourceViewsContainments, - ResourceViewsContainmentsList, + QueryIndices, + QueryIndicesList, ResourceViewsIndices, ResourceViewsIndicesList, - ResourceViewsCanonicalContainments, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndices, - ResourceViewsReshapeIndicesList, - EntryViewsContainments, - EntryViewsContainmentsList, - EntryViewsIndices, - EntryViewsIndicesList, - EntryViewsReshapeIndices, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndices, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainments, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndices, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndices, - EntryViewsOppositeInverseIndicesList, - EntryContainments, - EntryContainmentsList, + DisjointIndices, + DisjointIndicesList, EntryIndices, EntryIndicesList, - EntryReshapeIndices, - EntryReshapeIndicesList, > Cutoff< 'a, @@ -819,67 +714,16 @@ impl< ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - (SFI, SFIS), - (SVI, SVIS), - (SP, SPS), - (SI, SIS), - (SQ, SQS), - (ResourceViewsContainments, ResourceViewsContainmentsList), + (QueryIndices, QueryIndicesList), (ResourceViewsIndices, ResourceViewsIndicesList), - ( - ResourceViewsCanonicalContainments, - ResourceViewsCanonicalContainmentsList, - ), - (ResourceViewsReshapeIndices, ResourceViewsReshapeIndicesList), - (EntryViewsContainments, EntryViewsContainmentsList), - (EntryViewsIndices, EntryViewsIndicesList), - (EntryViewsReshapeIndices, EntryViewsReshapeIndicesList), - (EntryViewsInverseIndices, EntryViewsInverseIndicesList), - ( - EntryViewsOppositeContainments, - EntryViewsOppositeContainmentsList, - ), - (EntryViewsOppositeIndices, EntryViewsOppositeIndicesList), - ( - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeReshapeIndicesList, - ), - ( - EntryViewsOppositeInverseIndices, - EntryViewsOppositeInverseIndicesList, - ), - (EntryContainments, EntryContainmentsList), + (DisjointIndices, DisjointIndicesList), (EntryIndices, EntryIndicesList), - (EntryReshapeIndices, EntryReshapeIndicesList), > for (T, U) where - R: ContainsQuery<'a, T::Filter, SFI, T::Views, SVI, SP, SI, SQ>, + R: ContainsQuery<'a, T::Filter, T::Views, QueryIndices>, Resources: 'a, - T: Task< - 'a, - R, - Resources, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, - EntryIndices, - EntryReshapeIndices, - > + Send + T: Task<'a, R, Resources, QueryIndices, ResourceViewsIndices, DisjointIndices, EntryIndices> + + Send + 'a, U: Stager< 'a, @@ -894,26 +738,10 @@ where ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFIS, - SVIS, - SPS, - SIS, - SQS, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >, { type Stage = ( @@ -931,26 +759,10 @@ where ResourcesIndicesList, ResourcesContainmentsList, ResourcesInverseIndicesList, - SFIS, - SVIS, - SPS, - SIS, - SQS, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >>::Stage, ); type Remainder = >::Remainder; #[inline] diff --git a/src/system/schedule/stages.rs b/src/system/schedule/stages.rs index a5557c7e..92ab1d8f 100644 --- a/src/system/schedule/stages.rs +++ b/src/system/schedule/stages.rs @@ -18,26 +18,10 @@ pub trait Stages< 'a, R, Resources, - FI, - VI, - P, - I, - Q, - ResourceViewsContainmentsLists, + QueryIndicesLists, ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, + DisjointIndicesLists, EntryIndicesLists, - EntryReshapeIndicesLists, >: Send where R: Registry, { @@ -77,32 +61,7 @@ pub trait Stages< fn new_has_run() -> Self::HasRun; } -impl - Stages< - '_, - R, - Resources, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - Null, - > for Null +impl Stages<'_, R, Resources, Null, Null, Null, Null> for Null where R: Registry, { @@ -129,92 +88,23 @@ impl< Resources, T, U, - FI, - FIS, - VI, - VIS, - P, - PS, - I, - IS, - Q, - QS, - ResourceViewsContainmentsList, - ResourceViewsContainmentsLists, + QueryIndicesList, + QueryIndicesLists, ResourceViewsIndicesList, ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsList, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesList, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsList, - EntryViewsContainmentsLists, - EntryViewsIndicesList, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesList, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesList, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesList, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesList, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsList, - EntryContainmentsLists, + DisjointIndicesList, + DisjointIndicesLists, EntryIndicesList, EntryIndicesLists, - EntryReshapeIndicesList, - EntryReshapeIndicesLists, > Stages< 'a, R, Resources, - (FI, FIS), - (VI, VIS), - (P, PS), - (I, IS), - (Q, QS), - ( - ResourceViewsContainmentsList, - ResourceViewsContainmentsLists, - ), + (QueryIndicesList, QueryIndicesLists), (ResourceViewsIndicesList, ResourceViewsIndicesLists), - ( - ResourceViewsCanonicalContainmentsList, - ResourceViewsCanonicalContainmentsLists, - ), - ( - ResourceViewsReshapeIndicesList, - ResourceViewsReshapeIndicesLists, - ), - (EntryViewsContainmentsList, EntryViewsContainmentsLists), - (EntryViewsIndicesList, EntryViewsIndicesLists), - (EntryViewsReshapeIndicesList, EntryViewsReshapeIndicesLists), - (EntryViewsInverseIndicesList, EntryViewsInverseIndicesLists), - ( - EntryViewsOppositeContainmentsList, - EntryViewsOppositeContainmentsLists, - ), - ( - EntryViewsOppositeIndicesList, - EntryViewsOppositeIndicesLists, - ), - ( - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeReshapeIndicesLists, - ), - ( - EntryViewsOppositeInverseIndicesList, - EntryViewsOppositeInverseIndicesLists, - ), - (EntryContainmentsList, EntryContainmentsLists), + (DisjointIndicesList, DisjointIndicesLists), (EntryIndicesList, EntryIndicesLists), - (EntryReshapeIndicesList, EntryReshapeIndicesLists), > for (T, U) where R: Registry, @@ -222,51 +112,19 @@ where 'a, R, Resources, - FI, - VI, - P, - I, - Q, - ResourceViewsContainmentsList, + QueryIndicesList, ResourceViewsIndicesList, - ResourceViewsCanonicalContainmentsList, - ResourceViewsReshapeIndicesList, - EntryViewsContainmentsList, - EntryViewsIndicesList, - EntryViewsReshapeIndicesList, - EntryViewsInverseIndicesList, - EntryViewsOppositeContainmentsList, - EntryViewsOppositeIndicesList, - EntryViewsOppositeReshapeIndicesList, - EntryViewsOppositeInverseIndicesList, - EntryContainmentsList, + DisjointIndicesList, EntryIndicesList, - EntryReshapeIndicesList, >, U: Stages< 'a, R, Resources, - FIS, - VIS, - PS, - IS, - QS, - ResourceViewsContainmentsLists, + QueryIndicesLists, ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, + DisjointIndicesLists, EntryIndicesLists, - EntryReshapeIndicesLists, >, { type HasRun = T::HasRun; diff --git a/src/system/schedule/task/mod.rs b/src/system/schedule/task/mod.rs index f47f49ce..931467ce 100644 --- a/src/system/schedule/task/mod.rs +++ b/src/system/schedule/task/mod.rs @@ -11,7 +11,7 @@ use crate::hlist::define_null; define_null!(); /// A task that implements [`System`]. -pub struct System(pub S); +pub struct System(pub System); /// A task that implements [`ParSystem`]. -pub struct ParSystem

(pub P); +pub struct ParSystem(pub ParSystem); diff --git a/src/system/schedule/task/sealed.rs b/src/system/schedule/task/sealed.rs index 4f550127..c0e355f1 100644 --- a/src/system/schedule/task/sealed.rs +++ b/src/system/schedule/task/sealed.rs @@ -6,7 +6,6 @@ use super::{ }; use crate::{ query::{ - filter::Filter, view, view::Views, Query, @@ -23,124 +22,31 @@ use crate::{ }; /// A task that can be run in a schedule. -pub trait Task< - 'a, - R, - Resources, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, - EntryIndices, - EntryReshapeIndices, -> where +pub trait Task<'a, R, Resources, QueryIndices, ResourceViewsIndices, DisjointIndices, EntryIndices> +where R: Registry, { /// The components viewed by this task. - type Views: Views<'a> + Filter; + type Views: Views<'a> + Send; /// A filter applied to the components viewed by this task. - type Filter: Filter; + type Filter; /// Executes the task over the given world. fn run(&mut self, world: SendableWorld); } -impl< - 'a, - R, - Resources, - S, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, - EntryIndices, - EntryReshapeIndices, - > - Task< - 'a, - R, - Resources, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, - EntryIndices, - EntryReshapeIndices, - > for System +impl<'a, R, Resources, S, QueryIndices, ResourceViewsIndices, DisjointIndices, EntryIndices> + Task<'a, R, Resources, QueryIndices, ResourceViewsIndices, DisjointIndices, EntryIndices> + for System where S: system::System + Send, - R: ContainsQuery<'a, S::Filter, SFI, S::Views<'a>, SVI, SP, SI, SQ> - + registry::ContainsViews< - 'a, - S::EntryViews<'a>, - EntryContainments, - EntryIndices, - EntryReshapeIndices, - >, + R: ContainsQuery<'a, S::Filter, S::Views<'a>, QueryIndices> + + registry::ContainsViews<'a, S::EntryViews<'a>, EntryIndices>, Resources: 'a, - Resources: ContainsViews< - 'a, - S::ResourceViews<'a>, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - >, - S::EntryViews<'a>: view::Disjoint< - S::Views<'a>, - R, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - > + Views<'a>, + Resources: ContainsViews<'a, S::ResourceViews<'a>, ResourceViewsIndices>, + S::Views<'a>: Send, + S::ResourceViews<'a>: Send, + S::EntryViews<'a>: view::Disjoint, R, DisjointIndices> + Views<'a> + Send, { type Views = S::Views<'a>; type Filter = S::Filter; @@ -155,88 +61,18 @@ where } } -impl< - 'a, - P, - R, - Resources, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, - EntryIndices, - EntryReshapeIndices, - > - Task< - 'a, - R, - Resources, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, - EntryIndices, - EntryReshapeIndices, - > for ParSystem

+impl<'a, P, R, Resources, QueryIndices, ResourceViewsIndices, DisjointIndices, EntryIndices> + Task<'a, R, Resources, QueryIndices, ResourceViewsIndices, DisjointIndices, EntryIndices> + for ParSystem

where P: system::ParSystem + Send, - R: ContainsParQuery<'a, P::Filter, SFI, P::Views<'a>, SVI, SP, SI, SQ> - + registry::ContainsViews< - 'a, - P::EntryViews<'a>, - EntryContainments, - EntryIndices, - EntryReshapeIndices, - >, + R: ContainsParQuery<'a, P::Filter, P::Views<'a>, QueryIndices> + + registry::ContainsViews<'a, P::EntryViews<'a>, EntryIndices>, Resources: 'a, - Resources: ContainsViews< - 'a, - P::ResourceViews<'a>, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - >, - P::EntryViews<'a>: view::Disjoint< - P::Views<'a>, - R, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - > + Views<'a>, + Resources: ContainsViews<'a, P::ResourceViews<'a>, ResourceViewsIndices>, + P::Views<'a>: Send, + P::ResourceViews<'a>: Send, + P::EntryViews<'a>: view::Disjoint, R, DisjointIndices> + Views<'a> + Send, { type Views = P::Views<'a>; type Filter = P::Filter; diff --git a/src/world/entry.rs b/src/world/entry.rs index b5cb3781..c15eb75d 100644 --- a/src/world/entry.rs +++ b/src/world/entry.rs @@ -1,16 +1,11 @@ use crate::{ archetype, - component::Component, + component, entity::allocator::Location, + hlist::Reshape, query::{ - filter::{ - And, - Filter, - }, - view::{ - Reshape, - Views, - }, + filter::And, + view, Query, }, registry, @@ -18,7 +13,6 @@ use crate::{ contains::filter::Sealed as ContainsFilterSealed, ContainsComponent, ContainsQuery, - Registry, }, resource, world::World, @@ -53,19 +47,22 @@ use core::fmt; /// [`entity::Identifier`]: crate::entity::Identifier /// [`entry`]: crate::World::entry() /// [`World`]: crate::World -pub struct Entry<'a, R, Resources> +pub struct Entry<'a, Registry, Resources> where - R: Registry, + Registry: registry::Registry, { - world: &'a mut World, - location: Location, + world: &'a mut World, + location: Location, } -impl<'a, R, Resources> Entry<'a, R, Resources> +impl<'a, Registry, Resources> Entry<'a, Registry, Resources> where - R: Registry, + Registry: registry::Registry, { - pub(crate) fn new(world: &'a mut World, location: Location) -> Self { + pub(crate) fn new( + world: &'a mut World, + location: Location, + ) -> Self { Self { world, location } } @@ -93,12 +90,12 @@ where /// /// entry.add(Baz(1.5)); /// ``` - pub fn add(&mut self, component: C) + pub fn add(&mut self, component: Component) where - C: Component, - R: ContainsComponent, + Component: component::Component, + Registry: ContainsComponent, { - let component_index = R::LEN - R::INDEX - 1; + let component_index = Registry::LEN - Registry::INDEX - 1; if // SAFETY: The `component_index` obtained from `R::LEN - R::INDEX - 1` is guaranteed to be // a valid index into `self.location.identifier`, since an identifier has `R::LEN` bits. @@ -142,7 +139,7 @@ where let identifier_buffer = // SAFETY: Since `raw_identifier_buffer` was obtained from a valid identifier, it // is of the proper length (which is `(R::LEN + 7) / 8`). - unsafe { archetype::Identifier::::new(raw_identifier_buffer) }; + unsafe { archetype::Identifier::::new(raw_identifier_buffer) }; // Insert to the corresponding archetype using the bytes and the new component. let archetype = self @@ -166,14 +163,18 @@ where }; // Update the location. + // SAFETY: The archetype is guaranteed to outlive the location, as archetype is stored + // in the same world where the location is stored. Additionally, the location stored in + // this entry will be outlived by archetype due to its lifetime guarantees. + let location = Location::new(unsafe { archetype.identifier() }, index); // SAFETY: `entity_identifier` is guaranteed at creation of this `Entry` to be // contained in `self.world.entity_allocator`. unsafe { - self.world.entity_allocator.modify_location_unchecked( - entity_identifier, - Location::new(archetype.identifier(), index), - ); + self.world + .entity_allocator + .modify_location_unchecked(entity_identifier, location); } + self.location = location; } } @@ -200,12 +201,12 @@ where /// /// entry.remove::(); /// ``` - pub fn remove(&mut self) + pub fn remove(&mut self) where - C: Component, - R: ContainsComponent, + Component: component::Component, + Registry: ContainsComponent, { - let component_index = R::LEN - R::INDEX - 1; + let component_index = Registry::LEN - Registry::INDEX - 1; if // SAFETY: The `component_index` obtained from `R::LEN - R::INDEX - 1` is guaranteed to be // a valid index into `self.location.identifier`, since an identifier has `R::LEN` bits. @@ -235,7 +236,7 @@ where let identifier_buffer = // SAFETY: Since `raw_identifier_buffer` was obtained from a valid identifier, it // is of the proper length (which is `(R::LEN + 7) / 8`). - unsafe { archetype::Identifier::::new(raw_identifier_buffer) }; + unsafe { archetype::Identifier::::new(raw_identifier_buffer) }; // Insert to the corresponding archetype using the bytes, skipping the removed // component. @@ -252,21 +253,25 @@ where // Also, the registry `R` is invariantly guaranteed by the invariants in `World` to // not contain any duplicates. unsafe { - archetype.push_from_buffer_skipping_component::( + archetype.push_from_buffer_skipping_component::( entity_identifier, current_component_bytes.as_ptr(), ) }; // Update the location. + // SAFETY: The archetype is guaranteed to outlive the location, as archetype is stored + // in the same world where the location is stored. Additionally, the location stored in + // this entry will be outlived by archetype due to its lifetime guarantees. + let location = Location::new(unsafe { archetype.identifier() }, index); // SAFETY: `entity_identifier` is guaranteed at creation of this `Entry` to be // contained in `self.world.entity_allocator`. unsafe { - self.world.entity_allocator.modify_location_unchecked( - entity_identifier, - Location::new(archetype.identifier(), index), - ); + self.world + .entity_allocator + .modify_location_unchecked(entity_identifier, location); } + self.location = location; } } @@ -306,20 +311,23 @@ where /// assert_eq!(bar.0, true); /// ``` /// + /// [`Filter`]: crate::query::filter::Filter /// [`Views`]: trait@crate::query::view::Views - pub fn query<'b, V, F, VI, FI, P, I, Q>( + pub fn query<'b, Views, Filter, Indices>( &'b mut self, - #[allow(unused_variables)] query: Query, - ) -> Option + #[allow(unused_variables)] query: Query, + ) -> Option where - V: Views<'b> + Filter, - F: Filter, - R: ContainsQuery<'b, F, FI, V, VI, P, I, Q>, + Views: view::Views<'b>, + Registry: ContainsQuery<'b, Filter, Views, Indices>, { // SAFETY: The `R` on which `filter()` is called is the same `R` over which the identifier // is generic over. if unsafe { - , And>>::filter(self.location.identifier) + , + And, + >>::filter(self.location.identifier) } { Some( // SAFETY: Since the archetype wasn't filtered out by the views, then each @@ -333,7 +341,11 @@ where self.world .archetypes .get_mut(self.location.identifier)? - .view_row_unchecked::(self.location.index) + .view_row_unchecked::(self.location.index) .reshape() }, ) @@ -343,9 +355,9 @@ where } } -impl<'a, R, Resources> fmt::Debug for Entry<'a, R, Resources> +impl<'a, Registry, Resources> fmt::Debug for Entry<'a, Registry, Resources> where - R: registry::Debug, + Registry: registry::Debug, Resources: resource::Debug, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/world/impl_clone.rs b/src/world/impl_clone.rs index b16c0ecb..c14816c6 100644 --- a/src/world/impl_clone.rs +++ b/src/world/impl_clone.rs @@ -3,9 +3,9 @@ use crate::{ world::World, }; -impl Clone for World +impl Clone for World where - R: registry::Clone, + Registry: registry::Clone, Resources: Clone, { /// Performs a full clone of the `World` and all of its components. diff --git a/src/world/impl_debug.rs b/src/world/impl_debug.rs index 1b67b66b..ee419587 100644 --- a/src/world/impl_debug.rs +++ b/src/world/impl_debug.rs @@ -5,9 +5,9 @@ use crate::{ }; use core::fmt; -impl fmt::Debug for World +impl fmt::Debug for World where - R: registry::Debug, + Registry: registry::Debug, Resources: resource::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/src/world/impl_default.rs b/src/world/impl_default.rs index ef9eeb4a..6670ce8a 100644 --- a/src/world/impl_default.rs +++ b/src/world/impl_default.rs @@ -1,12 +1,12 @@ use crate::{ - registry::Registry, + registry, resource, World, }; -impl Default for World +impl Default for World where - R: Registry, + Registry: registry::Registry, Resources: resource::Resources + Default, { fn default() -> Self { diff --git a/src/world/impl_eq.rs b/src/world/impl_eq.rs index ce4694c6..eea7b60e 100644 --- a/src/world/impl_eq.rs +++ b/src/world/impl_eq.rs @@ -2,9 +2,9 @@ use super::World; use crate::registry; use core::cmp; -impl cmp::PartialEq for World +impl cmp::PartialEq for World where - R: registry::PartialEq, + Registry: registry::PartialEq, Resources: cmp::PartialEq, { fn eq(&self, other: &Self) -> bool { @@ -15,9 +15,9 @@ where } } -impl cmp::Eq for World +impl cmp::Eq for World where - R: registry::Eq, + Registry: registry::Eq, Resources: cmp::Eq, { } diff --git a/src/world/impl_send.rs b/src/world/impl_send.rs index 9a2ee804..478630fe 100644 --- a/src/world/impl_send.rs +++ b/src/world/impl_send.rs @@ -1,13 +1,13 @@ use crate::{ - registry::Registry, + registry, world::World, }; // SAFETY: This type is safe to send between threads, since all pointers are owned and cannot be // mutated without mutable access. -unsafe impl Send for World +unsafe impl Send for World where - R: Registry + Send, + Registry: registry::Registry + Send, Resources: Send, { } diff --git a/src/world/impl_serde.rs b/src/world/impl_serde.rs index 4681b365..1965712e 100644 --- a/src/world/impl_serde.rs +++ b/src/world/impl_serde.rs @@ -20,9 +20,9 @@ use serde::{ Serializer, }; -impl serde::Serialize for World +impl serde::Serialize for World where - R: registry::Serialize, + Registry: registry::Serialize, Resources: resource::Resources + resource::Serialize, { fn serialize(&self, serializer: S) -> Result @@ -37,30 +37,30 @@ where } } -impl<'de, R, Resources> serde::Deserialize<'de> for World +impl<'de, Registry, Resources> serde::Deserialize<'de> for World where - R: registry::Deserialize<'de>, + Registry: registry::Deserialize<'de>, Resources: resource::Resources + resource::Deserialize<'de>, { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct WorldVisitor<'de, R, Resources> + struct WorldVisitor<'de, Registry, Resources> where - R: registry::Deserialize<'de>, + Registry: registry::Deserialize<'de>, { lifetime: PhantomData<&'de ()>, - registry: PhantomData, + registry: PhantomData, resources: PhantomData, } - impl<'de, R, Resources> Visitor<'de> for WorldVisitor<'de, R, Resources> + impl<'de, Registry, Resources> Visitor<'de> for WorldVisitor<'de, Registry, Resources> where - R: registry::Deserialize<'de>, + Registry: registry::Deserialize<'de>, Resources: resource::Resources + resource::Deserialize<'de>, { - type Value = World; + type Value = World; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("serialized World") @@ -91,7 +91,7 @@ where deserializer.deserialize_tuple( 3, - WorldVisitor:: { + WorldVisitor:: { lifetime: PhantomData, registry: PhantomData, resources: PhantomData, @@ -168,10 +168,7 @@ mod tests { Token::TupleEnd, ]) ); - let mut deserializer = Deserializer::builder() - .tokens(tokens) - .self_describing(false) - .build(); + let mut deserializer = Deserializer::builder().tokens(tokens).build(); assert_ok_eq!( World::::deserialize(&mut deserializer), world @@ -388,7 +385,6 @@ mod tests { let mut deserializer = Deserializer::builder() .tokens(tokens) .is_human_readable(false) - .self_describing(false) .build(); assert_ok_eq!( World::::deserialize(&mut deserializer), @@ -429,10 +425,7 @@ mod tests { Token::TupleEnd, ]) ); - let mut deserializer = Deserializer::builder() - .tokens(tokens) - .self_describing(false) - .build(); + let mut deserializer = Deserializer::builder().tokens(tokens).build(); assert_ok_eq!( World::::deserialize(&mut deserializer), world @@ -444,7 +437,6 @@ mod tests { let mut deserializer = Deserializer::builder() .tokens(Tokens(vec![Token::Tuple { len: 0 }, Token::TupleEnd])) .is_human_readable(false) - .self_describing(false) .build(); assert_err_eq!( @@ -464,7 +456,6 @@ mod tests { Token::TupleEnd, ])) .is_human_readable(false) - .self_describing(false) .build(); assert_err_eq!( @@ -495,7 +486,6 @@ mod tests { Token::TupleEnd, ])) .is_human_readable(false) - .self_describing(false) .build(); assert_err_eq!( diff --git a/src/world/impl_sync.rs b/src/world/impl_sync.rs index e4933a76..4905ccdc 100644 --- a/src/world/impl_sync.rs +++ b/src/world/impl_sync.rs @@ -1,13 +1,13 @@ use crate::{ - registry::Registry, + registry, world::World, }; // SAFETY: This type is safe to share between multiple threads as you can't mutate it without a // &mut reference. -unsafe impl Sync for World +unsafe impl Sync for World where - R: Registry + Sync, + Registry: registry::Registry + Sync, Resources: Sync, { } diff --git a/src/world/mod.rs b/src/world/mod.rs index 9aed311a..a1740060 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -20,15 +20,11 @@ pub use entry::Entry; use crate::{ archetypes::Archetypes, entities, - entities::Entities, entity, - entity::Entity, query, query::{ - filter::Filter, result, view, - view::Views, Query, Result, }, @@ -38,14 +34,13 @@ use crate::{ ContainsEntities, ContainsEntity, ContainsQuery, - Registry, }, resource, resource::{ ContainsResource, ContainsViews, }, - system::System, + system, }; #[cfg(feature = "rayon")] use crate::{ @@ -58,9 +53,8 @@ use crate::{ ContainsParQuery, }, system::{ - schedule::Schedule, + schedule, schedule::Stages, - ParSystem, }, }; use alloc::vec::Vec; @@ -102,20 +96,20 @@ use hashbrown::HashSet; /// [`query()`]: crate::World::query() /// [`Registry`]: crate::registry::Registry /// [`System`]: crate::system::System -pub struct World +pub struct World where - R: Registry, + Registry: registry::Registry, { - pub(crate) archetypes: Archetypes, - pub(crate) entity_allocator: entity::Allocator, + pub(crate) archetypes: Archetypes, + pub(crate) entity_allocator: entity::Allocator, len: usize, resources: Resources, } -impl World +impl World where - R: Registry, + Registry: registry::Registry, { /// Creates an empty `World`. /// @@ -144,18 +138,18 @@ where } } -impl World +impl World where - R: Registry, + Registry: registry::Registry, { fn from_raw_parts( - archetypes: Archetypes, - entity_allocator: entity::Allocator, + archetypes: Archetypes, + entity_allocator: entity::Allocator, len: usize, resources: Resources, ) -> Self { - R::assert_no_duplicates(&mut HashSet::with_capacity_and_hasher( - R::LEN, + Registry::assert_no_duplicates(&mut HashSet::with_capacity_and_hasher( + Registry::LEN, FnvBuildHasher::default(), )); @@ -207,23 +201,22 @@ where /// /// let entity_identifier = world.insert(entity!(Foo(42), Bar(false))); /// ``` - pub fn insert(&mut self, entity: E) -> entity::Identifier + pub fn insert(&mut self, entity: Entity) -> entity::Identifier where - E: Entity, - R: ContainsEntity, + Registry: ContainsEntity, { self.len += 1; - let canonical_entity = R::canonical(entity); + let canonical_entity = Registry::canonical(entity); // SAFETY: Since the archetype was obtained using the `identifier_buffer` created from the - // entity `E`, then the entity is guaranteed to be made up of componpents identified by the - // archetype's identifier. + // entity `Entity`, then the entity is guaranteed to be made up of componpents identified + // by the archetype's identifier. // // `self.entity_allocator` is guaranteed to live as long as the archetype. unsafe { self.archetypes - .get_mut_or_insert_new_for_entity::<>::Canonical, Q>() + .get_mut_or_insert_new_for_entity::<>::Canonical, >::CanonicalContainments>() .push(canonical_entity, &mut self.entity_allocator) } } @@ -248,10 +241,12 @@ where /// /// let entity_identiifers = world.extend(entities![(Foo(1), Bar(false)), (Foo(2), Bar(true))]); /// ``` - pub fn extend(&mut self, entities: entities::Batch) -> Vec + pub fn extend( + &mut self, + entities: entities::Batch, + ) -> Vec where - E: Entities, - R: ContainsEntities, + Registry: ContainsEntities, { self.len += entities.len(); @@ -259,7 +254,7 @@ where // SAFETY: Since `entities` is already a `Batch`, then the canonical entities derived // from `entities` can safely be converted into a batch as well, since the components // will be of the same length. - unsafe { entities::Batch::new_unchecked(R::canonical(entities.entities)) }; + unsafe { entities::Batch::new_unchecked(Registry::canonical(entities.entities)) }; // SAFETY: Since the archetype was obtained using the `identifier_buffer` created from the // entities `E`, then the entities are guaranteed to be made up of componpents identified @@ -268,7 +263,7 @@ where // `self.entity_allocator` is guaranteed to live as long as the archetype. unsafe { self.archetypes - .get_mut_or_insert_new_for_entity::<<>::Canonical as entities::Contains>::Entity, Q>() + .get_mut_or_insert_new_for_entity::<<>::Canonical as entities::Contains>::Entity, >::CanonicalContainments>() .extend(canonical_entities, &mut self.entity_allocator) } } @@ -325,72 +320,31 @@ where /// [`Views`]: trait@crate::query::view::Views pub fn query< 'a, - V, - F, + Views, + Filter, ResourceViews, EntryViews, - VI, - FI, - P, - I, - Q, - ResourceViewsContainments, + QueryIndices, ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, + DisjointIndices, EntryIndices, - EntryReshapeIndices, >( &'a mut self, - #[allow(unused_variables)] query: Query, + #[allow(unused_variables)] query: Query, ) -> Result< - R, + Registry, Resources, - result::Iter<'a, R, F, FI, V, VI, P, I, Q>, + result::Iter<'a, Registry, Filter, Views, QueryIndices>, ResourceViews, EntryViews, - (EntryContainments, EntryIndices, EntryReshapeIndices), + EntryIndices, > where - V: Views<'a> + Filter, - F: Filter, - R: ContainsQuery<'a, F, FI, V, VI, P, I, Q> - + registry::ContainsViews< - 'a, - EntryViews, - EntryContainments, - EntryIndices, - EntryReshapeIndices, - >, - Resources: ContainsViews< - 'a, - ResourceViews, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - >, - EntryViews: view::Disjoint< - V, - R, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - > + Views<'a>, + Views: view::Views<'a>, + Registry: ContainsQuery<'a, Filter, Views, QueryIndices> + + registry::ContainsViews<'a, EntryViews, EntryIndices>, + Resources: ContainsViews<'a, ResourceViews, ResourceViewsIndices>, + EntryViews: view::Disjoint + view::Views<'a>, { let world = self as *mut Self; Result { @@ -461,72 +415,31 @@ where #[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))] pub fn par_query< 'a, - V, - F, + Views, + Filter, ResourceViews, EntryViews, - VI, - FI, - P, - I, - Q, - ResourceViewsContainments, + QueryIndices, ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, + DisjointIndices, EntryIndices, - EntryReshapeIndices, >( &'a mut self, - #[allow(unused_variables)] query: Query, + #[allow(unused_variables)] query: Query, ) -> Result< - R, + Registry, Resources, - result::ParIter<'a, R, F, FI, V, VI, P, I, Q>, + result::ParIter<'a, Registry, Filter, Views, QueryIndices>, ResourceViews, EntryViews, - (EntryContainments, EntryIndices, EntryReshapeIndices), + EntryIndices, > where - V: ParViews<'a> + Filter, - F: Filter, - R: ContainsParQuery<'a, F, FI, V, VI, P, I, Q> - + registry::ContainsViews< - 'a, - EntryViews, - EntryContainments, - EntryIndices, - EntryReshapeIndices, - >, - Resources: ContainsViews< - 'a, - ResourceViews, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - >, - EntryViews: view::Disjoint< - V, - R, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - > + Views<'a>, + Views: ParViews<'a>, + Registry: ContainsParQuery<'a, Filter, Views, QueryIndices> + + registry::ContainsViews<'a, EntryViews, EntryIndices>, + Resources: ContainsViews<'a, ResourceViews, ResourceViewsIndices>, + EntryViews: view::Disjoint + view::Views<'a>, { let world = self as *mut Self; Result { @@ -547,14 +460,13 @@ where /// `Archetypes` to which they belong. #[cfg(feature = "rayon")] #[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))] - pub(crate) unsafe fn query_archetype_claims<'a, V, F, VI, FI, P, I, Q>( + pub(crate) unsafe fn query_archetype_claims<'a, Views, Filter, FilterIndices, Indices>( &'a mut self, - #[allow(unused_variables)] query: Query, - ) -> result::ArchetypeClaims<'a, R, F, FI, V, VI, P, I, Q> + #[allow(unused_variables)] query: Query, + ) -> result::ArchetypeClaims<'a, Registry, Filter, Views, Indices> where - V: Views<'a> + Filter, - F: Filter, - R: ContainsFilter, And>, + Views: view::Views<'a>, + Registry: ContainsFilter, FilterIndices>, { // SAFETY: The safety contract here is upheld by the safety contract of this method. unsafe { result::ArchetypeClaims::new(self.archetypes.iter_mut()) } @@ -573,7 +485,7 @@ where /// Result, /// Views, /// }, - /// registry::ContainsQuery, + /// registry, /// system::System, /// Registry, /// World, @@ -594,18 +506,12 @@ where /// type ResourceViews<'a> = Views!(); /// type EntryViews<'a> = Views!(); /// - /// fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + /// fn run<'a, R, S, I, E>( /// &mut self, - /// query_results: Result< - /// R, - /// S, - /// result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - /// Self::ResourceViews<'a>, - /// Self::EntryViews<'a>, - /// (EP, EI, EQ), - /// >, + /// query_results: Result, Self::EntryViews<'a>, E>, /// ) where - /// R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + /// R: registry::Registry, + /// I: Iterator>, /// { /// for result!(foo, bar) in query_results.iter { /// // Increment `Foo` by `Bar`. @@ -623,66 +529,27 @@ where /// [`System`]: crate::system::System pub fn run_system< 'a, - S, - FI, - VI, - P, - I, - Q, - ResourceViewsContainments, + System, + QueryIndices, ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, + DisjointIndices, EntryIndices, - EntryReshapeIndices, >( &'a mut self, - system: &mut S, + system: &mut System, ) where - S: System, - R: ContainsQuery<'a, S::Filter, FI, S::Views<'a>, VI, P, I, Q> - + registry::ContainsViews< - 'a, - S::EntryViews<'a>, - EntryContainments, - EntryIndices, - EntryReshapeIndices, - >, - Resources: ContainsViews< - 'a, - S::ResourceViews<'a>, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - >, - S::EntryViews<'a>: view::Disjoint< - S::Views<'a>, - R, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - > + Views<'a>, + System: system::System, + Registry: ContainsQuery<'a, System::Filter, System::Views<'a>, QueryIndices> + + registry::ContainsViews<'a, System::EntryViews<'a>, EntryIndices>, + Resources: ContainsViews<'a, System::ResourceViews<'a>, ResourceViewsIndices>, + System::EntryViews<'a>: + view::Disjoint, Registry, DisjointIndices> + view::Views<'a>, { let result = self.query(Query::< - S::Views<'a>, - S::Filter, - S::ResourceViews<'a>, - S::EntryViews<'a>, + System::Views<'a>, + System::Filter, + System::ResourceViews<'a>, + System::EntryViews<'a>, >::new()); system.run(result); } @@ -700,7 +567,7 @@ where /// Result, /// Views, /// }, - /// registry::ContainsParQuery, + /// registry, /// system::ParSystem, /// Registry, /// World, @@ -722,18 +589,12 @@ where /// type ResourceViews<'a> = Views!(); /// type EntryViews<'a> = Views!(); /// - /// fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + /// fn run<'a, R, S, I, E>( /// &mut self, - /// query_results: Result< - /// R, - /// S, - /// result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - /// Self::ResourceViews<'a>, - /// Self::EntryViews<'a>, - /// (EP, EI, EQ), - /// >, + /// query_results: Result, Self::EntryViews<'a>, E>, /// ) where - /// R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + /// R: registry::Registry, + /// I: ParallelIterator>, /// { /// query_results /// .iter @@ -752,66 +613,27 @@ where #[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))] pub fn run_par_system< 'a, - S, - FI, - VI, - P, - I, - Q, - ResourceViewsContainments, + ParSystem, + QueryIndices, ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - EntryContainments, + DisjointIndices, EntryIndices, - EntryReshapeIndices, >( &'a mut self, - par_system: &mut S, + par_system: &mut ParSystem, ) where - S: ParSystem, - R: ContainsParQuery<'a, S::Filter, FI, S::Views<'a>, VI, P, I, Q> - + registry::ContainsViews< - 'a, - S::EntryViews<'a>, - EntryContainments, - EntryIndices, - EntryReshapeIndices, - >, - Resources: ContainsViews< - 'a, - S::ResourceViews<'a>, - ResourceViewsContainments, - ResourceViewsIndices, - ResourceViewsCanonicalContainments, - ResourceViewsReshapeIndices, - >, - S::EntryViews<'a>: view::Disjoint< - S::Views<'a>, - R, - EntryViewsContainments, - EntryViewsIndices, - EntryViewsReshapeIndices, - EntryViewsInverseIndices, - EntryViewsOppositeContainments, - EntryViewsOppositeIndices, - EntryViewsOppositeReshapeIndices, - EntryViewsOppositeInverseIndices, - > + Views<'a>, + ParSystem: system::ParSystem, + Registry: ContainsParQuery<'a, ParSystem::Filter, ParSystem::Views<'a>, QueryIndices> + + registry::ContainsViews<'a, ParSystem::EntryViews<'a>, EntryIndices>, + Resources: ContainsViews<'a, ParSystem::ResourceViews<'a>, ResourceViewsIndices>, + ParSystem::EntryViews<'a>: + view::Disjoint, Registry, DisjointIndices> + view::Views<'a>, { let result = self.par_query(Query::< - S::Views<'a>, - S::Filter, - S::ResourceViews<'a>, - S::EntryViews<'a>, + ParSystem::Views<'a>, + ParSystem::Filter, + ParSystem::ResourceViews<'a>, + ParSystem::EntryViews<'a>, >::new()); par_system.run(result); } @@ -829,7 +651,7 @@ where /// Result, /// Views, /// }, - /// registry::ContainsQuery, + /// registry, /// system::{ /// schedule, /// schedule::task, @@ -856,18 +678,12 @@ where /// type ResourceViews<'a> = Views!(); /// type EntryViews<'a> = Views!(); /// - /// fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + /// fn run<'a, R, S, I, E>( /// &mut self, - /// query_results: Result< - /// R, - /// S, - /// result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - /// Self::ResourceViews<'a>, - /// Self::EntryViews<'a>, - /// (EP, EI, EQ), - /// >, + /// query_results: Result, Self::EntryViews<'a>, E>, /// ) where - /// R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + /// R: registry::Registry, + /// I: Iterator>, /// { /// for result!(foo) in query_results.iter { /// foo.0 += 1; @@ -881,18 +697,12 @@ where /// type ResourceViews<'a> = Views!(); /// type EntryViews<'a> = Views!(); /// - /// fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + /// fn run<'a, R, S, I, E>( /// &mut self, - /// query_results: Result< - /// R, - /// S, - /// result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - /// Self::ResourceViews<'a>, - /// Self::EntryViews<'a>, - /// (EP, EI, EQ), - /// >, + /// query_results: Result, Self::EntryViews<'a>, E>, /// ) where - /// R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + /// R: registry::Registry, + /// I: Iterator>, /// { /// for result!(bar) in query_results.iter { /// bar.0 += 1; @@ -912,74 +722,13 @@ where /// [`Schedule`]: trait@crate::system::schedule::Schedule #[cfg(feature = "rayon")] #[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))] - pub fn run_schedule< - 'a, - S, - I, - P, - RI, - MergeParametersList, - ResourcesIndicesLists, - ResourcesContainmentsLists, - ResourcesInverseIndicesLists, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsLists, - ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, - EntryIndicesLists, - EntryReshapeIndicesLists, - >( - &mut self, - schedule: &'a mut S, - ) where - S: Schedule< - 'a, - R, - Resources, - I, - P, - RI, - MergeParametersList, - ResourcesIndicesLists, - ResourcesContainmentsLists, - ResourcesInverseIndicesLists, - SFI, - SVI, - SP, - SI, - SQ, - ResourceViewsContainmentsLists, - ResourceViewsIndicesLists, - ResourceViewsCanonicalContainmentsLists, - ResourceViewsReshapeIndicesLists, - EntryViewsContainmentsLists, - EntryViewsIndicesLists, - EntryViewsReshapeIndicesLists, - EntryViewsInverseIndicesLists, - EntryViewsOppositeContainmentsLists, - EntryViewsOppositeIndicesLists, - EntryViewsOppositeReshapeIndicesLists, - EntryViewsOppositeInverseIndicesLists, - EntryContainmentsLists, - EntryIndicesLists, - EntryReshapeIndicesLists, - >, + pub fn run_schedule<'a, Schedule, Indices>(&mut self, schedule: &'a mut Schedule) + where + Schedule: schedule::Schedule<'a, Registry, Resources, Indices>, { - schedule.as_stages().run(self, S::Stages::new_has_run()); + schedule + .as_stages() + .run(self, Schedule::Stages::new_has_run()); } /// Returns `true` if the world contains an entity identified by `entity_identifier`. @@ -1038,7 +787,10 @@ where /// [`Entry`]: crate::world::Entry /// [`None`]: Option::None #[must_use] - pub fn entry(&mut self, entity_identifier: entity::Identifier) -> Option> { + pub fn entry( + &mut self, + entity_identifier: entity::Identifier, + ) -> Option> { self.entity_allocator .get(entity_identifier) .map(|location| Entry::new(self, location)) @@ -1221,23 +973,22 @@ where /// /// let mut world = World::::new(); /// - /// world.reserve::(10); + /// world.reserve::(10); /// ``` - pub fn reserve(&mut self, additional: usize) + pub fn reserve(&mut self, additional: usize) where - E: Entity, - R: ContainsEntity, + Registry: ContainsEntity, { // SAFETY: Since the canonical entity form is used, the archetype obtained is guaranteed to - // be the unique archetype for entities of type `E`. + // be the unique archetype for entities of type `Entity`. // // Additionally, the same entity type is used for the call to `reserve`, meaning that the // set of components in the entity are guaranteed to be the same set as those in the // archetype. unsafe { self.archetypes - .get_mut_or_insert_new_for_entity::<>::Canonical, Q>() - .reserve::<>::Canonical>(additional); + .get_mut_or_insert_new_for_entity::<>::Canonical, >::CanonicalContainments>() + .reserve::<>::Canonical>(additional); } } @@ -1319,19 +1070,16 @@ where /// let mut world = /// World::::with_resources(resources!(ResourceA(0), ResourceB('a'))); /// - /// let result!(a, b) = world.view_resources::(); + /// let result!(a, b) = world.view_resources::(); /// /// assert_eq!(a, &ResourceA(0)); /// /// b.0 = 'b'; /// assert_eq!(b, &mut ResourceB('b')); /// ``` - pub fn view_resources<'a, Views, Containments, Indices, CanonicalContainments, ReshapeIndices>( - &'a mut self, - ) -> Views + pub fn view_resources<'a, Views, Indices>(&'a mut self) -> Views where - Resources: - ContainsViews<'a, Views, Containments, Indices, CanonicalContainments, ReshapeIndices>, + Resources: ContainsViews<'a, Views, Indices>, { self.resources.view() } @@ -1339,7 +1087,9 @@ where #[cfg(test)] mod tests { - use super::*; + use super::World; + #[cfg(feature = "rayon")] + use crate::system::ParSystem; #[cfg(feature = "rayon")] use crate::system::{ schedule, @@ -1352,13 +1102,20 @@ mod tests { filter, result, view, + Result, Views, }, + registry, resources, + system::System, Entity, + Query, Registry, }; - use alloc::vec; + use alloc::{ + vec, + vec::Vec, + }; use claims::{ assert_none, assert_some, @@ -1897,18 +1654,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { let mut result = query_results.iter.map(|result!(a)| a.0).collect::>(); result.sort(); @@ -1936,18 +1687,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { let mut result = query_results.iter.map(|result!(b)| b.0).collect::>(); result.sort(); @@ -1975,18 +1720,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { let mut result = query_results .iter @@ -2017,18 +1756,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { let mut result = query_results .iter @@ -2061,18 +1794,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { let result = query_results .iter @@ -2102,18 +1829,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { let result = query_results.iter.map(|result!(a)| a.0).collect::>(); assert_eq!(result, vec![1]); @@ -2140,18 +1861,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { let result = query_results.iter.map(|result!(a)| a.0).collect::>(); assert_eq!(result, vec![2]); @@ -2178,18 +1893,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { let result = query_results.iter.map(|result!(a)| a.0).collect::>(); assert_eq!(result, vec![1]); @@ -2216,18 +1925,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { let mut result = query_results.iter.map(|result!(a)| a.0).collect::>(); result.sort(); @@ -2257,18 +1960,12 @@ mod tests { type ResourceViews<'a> = Views!(&'a mut Counter); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { let result!(counter) = query_results.resources; counter.0 = query_results.iter.count(); @@ -2298,18 +1995,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { let mut result = query_results.iter.map(|result!(a)| a.0).collect::>(); result.sort(); @@ -2338,18 +2029,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { let mut result = query_results.iter.map(|result!(b)| b.0).collect::>(); result.sort(); @@ -2378,18 +2063,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { let mut result = query_results .iter @@ -2421,18 +2100,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { let mut result = query_results .iter @@ -2466,18 +2139,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { let result = query_results .iter @@ -2508,18 +2175,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { let result = query_results.iter.map(|result!(a)| a.0).collect::>(); assert_eq!(result, vec![1]); @@ -2547,18 +2208,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { let result = query_results.iter.map(|result!(a)| a.0).collect::>(); assert_eq!(result, vec![2]); @@ -2586,18 +2241,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { let result = query_results.iter.map(|result!(a)| a.0).collect::>(); assert_eq!(result, vec![1]); @@ -2625,18 +2274,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { let mut result = query_results.iter.map(|result!(a)| a.0).collect::>(); result.sort(); @@ -2667,18 +2310,12 @@ mod tests { type ResourceViews<'a> = Views!(&'a mut Counter); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { let result!(counter) = query_results.resources; counter.0 = query_results.iter.count(); @@ -2708,18 +2345,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { let mut result = query_results.iter.map(|result!(a)| a.0).collect::>(); result.sort(); @@ -2735,18 +2366,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: ParallelIterator>, { let mut result = query_results.iter.map(|result!(b)| b.0).collect::>(); result.sort(); @@ -2786,18 +2411,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { for result!(a, b) in query_results.iter { core::mem::swap(&mut a.0, &mut b.0); @@ -2813,18 +2432,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { for result!(a, c) in query_results.iter { core::mem::swap(&mut a.0, &mut c.0); @@ -2862,18 +2475,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { for result!(a, b) in query_results.iter { core::mem::swap(&mut a.0, &mut b.0); @@ -2889,18 +2496,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { for result!(a, c) in query_results.iter { core::mem::swap(&mut a.0, &mut c.0); @@ -2916,18 +2517,12 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - query_results: Result< - R, - S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, - Self::ResourceViews<'a>, - Self::EntryViews<'a>, - (EP, EI, EQ), - >, + query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + R: registry::Registry, + I: Iterator>, { for result!(a, _b, c) in query_results.iter { core::mem::swap(&mut a.0, &mut c.0); @@ -3101,6 +2696,21 @@ mod tests { assert_none!(world.entry(entity_identifier)); } + #[test] + fn entry_multiple_shape_changes() { + let mut world = World::::new(); + + let entity_identifier = world.insert(entity!(A(1), B('a'))); + let mut entry = assert_some!(world.entry(entity_identifier)); + + entry.remove::(); + entry.remove::(); + + assert_none!( + entry.query(Query::, filter::Has>>::new()) + ); + } + #[test] fn remove() { let mut world = World::::new(); @@ -3211,7 +2821,7 @@ mod tests { fn reserve() { let mut world = World::::new(); - world.reserve::(10); + world.reserve::(10); } #[test] @@ -3219,11 +2829,11 @@ mod tests { let mut world = World::::new(); world.insert(entity!(A(1))); - world.reserve::(10); + world.reserve::(10); } #[test] - fn reserve_creates_new_archetyps() { + fn reserve_creates_new_archetypes() { let mut world = World::::new(); world.insert(entity!(A(42))); world.extend(entities!((B('a')); 5)); @@ -3232,9 +2842,9 @@ mod tests { world.clone_from(&source_world); - source_world.reserve::(0); - source_world.reserve::(0); - source_world.reserve::(0); + source_world.reserve::(0); + source_world.reserve::(0); + source_world.reserve::(0); assert_eq!(world, source_world); } @@ -3275,7 +2885,7 @@ mod tests { fn view_no_resources() { let mut world = World::::new(); - let null = world.view_resources::(); + let null = world.view_resources::(); assert_eq!(null, view::Null); } @@ -3283,7 +2893,7 @@ mod tests { fn view_resource_immutably() { let mut world = World::::with_resources(resources!(A(42))); - let result!(a) = world.view_resources::(); + let result!(a) = world.view_resources::(); assert_eq!(a, &A(42)); } @@ -3291,7 +2901,7 @@ mod tests { fn view_resource_mutably() { let mut world = World::::with_resources(resources!(A(42))); - let result!(a) = world.view_resources::(); + let result!(a) = world.view_resources::(); assert_eq!(a, &mut A(42)); } @@ -3299,7 +2909,7 @@ mod tests { fn view_resource_mutably_modifying() { let mut world = World::::with_resources(resources!(A(42))); - let result!(a) = world.view_resources::(); + let result!(a) = world.view_resources::(); a.0 = 100; assert_eq!(a, &mut A(100)); @@ -3309,7 +2919,7 @@ mod tests { fn view_multiple_resources() { let mut world = World::::with_resources(resources!(A(42), B('a'))); - let result!(a, b) = world.view_resources::(); + let result!(a, b) = world.view_resources::(); assert_eq!(a, &A(42)); assert_eq!(b, &mut B('a')); @@ -3319,7 +2929,7 @@ mod tests { fn view_multiple_resources_reshaped() { let mut world = World::::with_resources(resources!(A(42), B('a'))); - let result!(b, a) = world.view_resources::(); + let result!(b, a) = world.view_resources::(); assert_eq!(a, &A(42)); assert_eq!(b, &mut B('a')); @@ -3329,7 +2939,7 @@ mod tests { fn view_multiple_resources_modifying() { let mut world = World::::with_resources(resources!(A(42), B('a'))); - let result!(a, b) = world.view_resources::(); + let result!(a, b) = world.view_resources::(); b.0 = 'b'; assert_eq!(a, &A(42)); @@ -3340,7 +2950,7 @@ mod tests { fn view_multiple_resources_modifying_reshaped() { let mut world = World::::with_resources(resources!(A(42), B('a'))); - let result!(b, a) = world.view_resources::(); + let result!(b, a) = world.view_resources::(); a.0 = 100; assert_eq!(a, &A(100)); @@ -3353,7 +2963,7 @@ mod tests { let mut world = World::::with_resources(resources!(A(42), B('a'), C)); - let result!(b) = world.view_resources::(); + let result!(b) = world.view_resources::(); assert_eq!(b, &B('a')); } @@ -3399,20 +3009,20 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(&'a A); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, mut query_result: Result< 'a, R, S, - result::Iter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + I, Self::ResourceViews<'a>, Self::EntryViews<'a>, - (EP, EI, EQ), + E, >, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q> - + registry::ContainsViews<'a, Self::EntryViews<'a>, EP, EI, EQ>, + R: registry::ContainsViews<'a, Self::EntryViews<'a>, E>, + I: Iterator>, { for result!() in query_result.iter { let mut entry = @@ -3442,20 +3052,20 @@ mod tests { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(&'a A); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, mut query_result: Result< 'a, R, S, - result::ParIter<'a, R, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q>, + I, Self::ResourceViews<'a>, Self::EntryViews<'a>, - (EP, EI, EQ), + E, >, ) where - R: ContainsParQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q> - + registry::ContainsViews<'a, Self::EntryViews<'a>, EP, EI, EQ>, + R: registry::ContainsViews<'a, Self::EntryViews<'a>, E>, + I: ParallelIterator>, { // Using the Entries during parallel iteration is not supported. let mut entry = assert_some!(query_result.entries.entry(self.entity_identifier)); diff --git a/tests/trybuild/schedule/non_send_entry_views.rs b/tests/trybuild/schedule/non_send_entry_views.rs new file mode 100644 index 00000000..2680dae2 --- /dev/null +++ b/tests/trybuild/schedule/non_send_entry_views.rs @@ -0,0 +1,36 @@ +use brood::{query::{Views, filter, Result}, registry, World, Registry, system::{System, schedule}}; +// This import is technically unused, since the macro fails to compile before it would be consumed. +// I'm leaving it here, though, for completeness; user code would use this module, and these tests +// should do their best to simulate user code. +#[allow(unused_imports)] +use brood::system::schedule::task; +use std::rc::Rc; + +struct A; + +struct Foo; + +impl System for Foo { + type Views<'a> = Views!(); + type Filter = filter::None; + type ResourceViews<'a> = Views!(); + type EntryViews<'a> = Views!(&'a Rc); + + fn run<'a, R, S, I, E>( + &mut self, + _query_results: Result, Self::EntryViews<'a>, E>, + ) where + R: registry::Registry, + I: Iterator>, + { + unimplemented!() + } +} + +fn main() { + let mut world = World::)>::new(); + + let schedule = schedule!(task::System(Foo)); + + world.run_schedule(&mut schedule); +} diff --git a/tests/trybuild/schedule/non_send_entry_views.stderr b/tests/trybuild/schedule/non_send_entry_views.stderr new file mode 100644 index 00000000..04e6954d --- /dev/null +++ b/tests/trybuild/schedule/non_send_entry_views.stderr @@ -0,0 +1,21 @@ +error[E0277]: `Rc` cannot be shared between threads safely + --> tests/trybuild/schedule/non_send_entry_views.rs:35:24 + | +35 | world.run_schedule(&mut schedule); + | ------------ ^^^^^^^^^^^^^ `Rc` cannot be shared between threads safely + | | + | required by a bound introduced by this call + | + = help: the trait `Sync` is not implemented for `Rc` + = note: required for `&Rc` to implement `Send` + = note: required because it appears within the type `(&Rc, Null)` + = note: required for `brood::system::schedule::task::System` to implement `brood::system::schedule::task::sealed::Task<'_, (Rc, brood::registry::Null), brood::resource::Null, (registry::contains::Null, registry::contains::Null, (registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), (resource::contains::Null, resource::contains::Null, resource::contains::Null, resource::contains::Null), (((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), view::disjoint::Null, ((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), view::disjoint::Null), ((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null))>` + = note: required for `(brood::system::schedule::task::System, brood::system::schedule::task::Null)` to implement `schedule::stager::Cutoff<'_, (Rc, brood::registry::Null), brood::resource::Null, schedule::claim::decision::Append, ((&Rc, brood::query::view::Null), schedule::claim::Null), schedule::stager::Null, schedule::stager::Null, schedule::stager::Null, schedule::stager::Null, (brood::query::view::Null, schedule::claim::Null), schedule::stager::Null, schedule::stager::Null, schedule::stager::Null, ((registry::contains::Null, registry::contains::Null, (registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), schedule::stage::Null), ((resource::contains::Null, resource::contains::Null, resource::contains::Null, resource::contains::Null), schedule::stage::Null), ((((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), view::disjoint::Null, ((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), view::disjoint::Null), schedule::stage::Null), (((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), schedule::stage::Null)>` + = note: required for `(brood::system::schedule::task::System, brood::system::schedule::task::Null)` to implement `schedule::scheduler::Scheduler<'_, (Rc, brood::registry::Null), brood::resource::Null, ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), (((((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), ((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), (view::merge::Neither, (view::merge::Right, view::merge::Null))), schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), (((registry::contains::Null, registry::contains::Null, (registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), schedule::stage::Null), schedule::stages::Null), (((resource::contains::Null, resource::contains::Null, resource::contains::Null, resource::contains::Null), schedule::stage::Null), schedule::stages::Null), (((((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), view::disjoint::Null, ((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), view::disjoint::Null), schedule::stage::Null), schedule::stages::Null), ((((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), schedule::stage::Null), schedule::stages::Null)>` + = note: required for `(brood::system::schedule::task::System, brood::system::schedule::task::Null)` to implement `schedule::sealed::Sealed<'_, (Rc, brood::registry::Null), brood::resource::Null, (((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), (((((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), ((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), (view::merge::Neither, (view::merge::Right, view::merge::Null))), schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), (((registry::contains::Null, registry::contains::Null, (registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), schedule::stage::Null), schedule::stages::Null), (((resource::contains::Null, resource::contains::Null, resource::contains::Null, resource::contains::Null), schedule::stage::Null), schedule::stages::Null), (((((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), view::disjoint::Null, ((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), view::disjoint::Null), schedule::stage::Null), schedule::stages::Null), ((((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), schedule::stage::Null), schedule::stages::Null))>` + = note: required for `(brood::system::schedule::task::System, brood::system::schedule::task::Null)` to implement `Schedule<'_, (Rc, brood::registry::Null), brood::resource::Null, (((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), (((((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), ((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), (view::merge::Neither, (view::merge::Right, view::merge::Null))), schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), (((registry::contains::Null, registry::contains::Null, (registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), schedule::stage::Null), schedule::stages::Null), (((resource::contains::Null, resource::contains::Null, resource::contains::Null, resource::contains::Null), schedule::stage::Null), schedule::stages::Null), (((((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), view::disjoint::Null, ((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), view::disjoint::Null), schedule::stage::Null), schedule::stages::Null), ((((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), schedule::stage::Null), schedule::stages::Null))>` +note: required by a bound in `World::::run_schedule` + --> src/world/mod.rs + | + | Schedule: schedule::Schedule<'a, Registry, Resources, Indices>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `World::::run_schedule` diff --git a/tests/trybuild/schedule/non_send_resource_views.rs b/tests/trybuild/schedule/non_send_resource_views.rs new file mode 100644 index 00000000..e212153a --- /dev/null +++ b/tests/trybuild/schedule/non_send_resource_views.rs @@ -0,0 +1,36 @@ +use brood::{query::{Views, filter, Result}, registry, World, Registry, resources, system::{System, schedule}}; +// This import is technically unused, since the macro fails to compile before it would be consumed. +// I'm leaving it here, though, for completeness; user code would use this module, and these tests +// should do their best to simulate user code. +#[allow(unused_imports)] +use brood::system::schedule::task; +use std::rc::Rc; + +struct A; + +struct Foo; + +impl System for Foo { + type Views<'a> = Views!(); + type Filter = filter::None; + type ResourceViews<'a> = Views!(&'a Rc); + type EntryViews<'a> = Views!(); + + fn run<'a, R, S, I, E>( + &mut self, + _query_results: Result, Self::EntryViews<'a>, E>, + ) where + R: registry::Registry, + I: Iterator>, + { + unimplemented!() + } +} + +fn main() { + let mut world = World::::with_resources(resources!(Rc::new(A))); + + let schedule = schedule!(task::System(Foo)); + + world.run_schedule(&mut schedule); +} diff --git a/tests/trybuild/schedule/non_send_resource_views.stderr b/tests/trybuild/schedule/non_send_resource_views.stderr new file mode 100644 index 00000000..4d803af2 --- /dev/null +++ b/tests/trybuild/schedule/non_send_resource_views.stderr @@ -0,0 +1,21 @@ +error[E0277]: `Rc` cannot be shared between threads safely + --> tests/trybuild/schedule/non_send_resource_views.rs:35:24 + | +35 | world.run_schedule(&mut schedule); + | ------------ ^^^^^^^^^^^^^ `Rc` cannot be shared between threads safely + | | + | required by a bound introduced by this call + | + = help: the trait `Sync` is not implemented for `Rc` + = note: required for `&Rc` to implement `Send` + = note: required because it appears within the type `(&Rc, Null)` + = note: required for `brood::system::schedule::task::System` to implement `brood::system::schedule::task::sealed::Task<'_, brood::registry::Null, (Rc, brood::resource::Null), (registry::contains::Null, registry::contains::Null, (registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), ((resource::contains::Contained, resource::contains::Null), (view::resource::get::index::Index, resource::contains::Null), (resource::contains::Contained, resource::contains::Null), (view::resource::get::index::Index, resource::contains::Null)), (((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), view::disjoint::Null, ((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), view::disjoint::Null), ((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null)>` + = note: required for `(brood::system::schedule::task::System, brood::system::schedule::task::Null)` to implement `schedule::stager::Cutoff<'_, brood::registry::Null, (Rc, brood::resource::Null), schedule::claim::decision::Append, (brood::query::view::Null, schedule::claim::Null), schedule::stager::Null, schedule::stager::Null, schedule::stager::Null, schedule::stager::Null, ((&Rc, brood::query::view::Null), schedule::claim::Null), schedule::stager::Null, schedule::stager::Null, schedule::stager::Null, ((registry::contains::Null, registry::contains::Null, (registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), schedule::stage::Null), (((resource::contains::Contained, resource::contains::Null), (view::resource::get::index::Index, resource::contains::Null), (resource::contains::Contained, resource::contains::Null), (view::resource::get::index::Index, resource::contains::Null)), schedule::stage::Null), ((((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), view::disjoint::Null, ((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), view::disjoint::Null), schedule::stage::Null), (((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), schedule::stage::Null)>` + = note: required for `(brood::system::schedule::task::System, brood::system::schedule::task::Null)` to implement `schedule::scheduler::Scheduler<'_, brood::registry::Null, (Rc, brood::resource::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), (((((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), ((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), (view::merge::Neither, view::merge::Null)), schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), (((registry::contains::Null, registry::contains::Null, (registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), schedule::stage::Null), schedule::stages::Null), ((((resource::contains::Contained, resource::contains::Null), (view::resource::get::index::Index, resource::contains::Null), (resource::contains::Contained, resource::contains::Null), (view::resource::get::index::Index, resource::contains::Null)), schedule::stage::Null), schedule::stages::Null), (((((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), view::disjoint::Null, ((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), view::disjoint::Null), schedule::stage::Null), schedule::stages::Null), ((((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), schedule::stage::Null), schedule::stages::Null)>` + = note: required for `(brood::system::schedule::task::System, brood::system::schedule::task::Null)` to implement `schedule::sealed::Sealed<'_, brood::registry::Null, (Rc, brood::resource::Null), (((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), (((((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), ((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), (view::merge::Neither, view::merge::Null)), schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), (((registry::contains::Null, registry::contains::Null, (registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), schedule::stage::Null), schedule::stages::Null), ((((resource::contains::Contained, resource::contains::Null), (view::resource::get::index::Index, resource::contains::Null), (resource::contains::Contained, resource::contains::Null), (view::resource::get::index::Index, resource::contains::Null)), schedule::stage::Null), schedule::stages::Null), (((((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), view::disjoint::Null, ((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), view::disjoint::Null), schedule::stage::Null), schedule::stages::Null), ((((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), schedule::stage::Null), schedule::stages::Null))>` + = note: required for `(brood::system::schedule::task::System, brood::system::schedule::task::Null)` to implement `Schedule<'_, brood::registry::Null, (Rc, brood::resource::Null), (((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), (((((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), ((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), (view::merge::Neither, view::merge::Null)), schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), (((registry::contains::Null, registry::contains::Null, (registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), schedule::stage::Null), schedule::stages::Null), ((((resource::contains::Contained, resource::contains::Null), (view::resource::get::index::Index, resource::contains::Null), (resource::contains::Contained, resource::contains::Null), (view::resource::get::index::Index, resource::contains::Null)), schedule::stage::Null), schedule::stages::Null), (((((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), view::disjoint::Null, ((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), view::disjoint::Null), schedule::stage::Null), schedule::stages::Null), ((((registry::contains::NotContained, registry::contains::Null), registry::contains::Null, brood::hlist::Null), schedule::stage::Null), schedule::stages::Null))>` +note: required by a bound in `World::::run_schedule` + --> src/world/mod.rs + | + | Schedule: schedule::Schedule<'a, Registry, Resources, Indices>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `World::::run_schedule` diff --git a/tests/trybuild/schedule/non_send_views.rs b/tests/trybuild/schedule/non_send_views.rs new file mode 100644 index 00000000..ee145b37 --- /dev/null +++ b/tests/trybuild/schedule/non_send_views.rs @@ -0,0 +1,36 @@ +use brood::{query::{Views, filter, Result}, registry, World, Registry, system::{System, schedule}}; +// This import is technically unused, since the macro fails to compile before it would be consumed. +// I'm leaving it here, though, for completeness; user code would use this module, and these tests +// should do their best to simulate user code. +#[allow(unused_imports)] +use brood::system::schedule::task; +use std::rc::Rc; + +struct A; + +struct Foo; + +impl System for Foo { + type Views<'a> = Views!(&'a Rc); + type Filter = filter::None; + type ResourceViews<'a> = Views!(); + type EntryViews<'a> = Views!(); + + fn run<'a, R, S, I, E>( + &mut self, + _query_results: Result, Self::EntryViews<'a>, E>, + ) where + R: registry::Registry, + I: Iterator>, + { + unimplemented!() + } +} + +fn main() { + let mut world = World::)>::new(); + + let schedule = schedule!(task::System(Foo)); + + world.run_schedule(&mut schedule); +} diff --git a/tests/trybuild/schedule/non_send_views.stderr b/tests/trybuild/schedule/non_send_views.stderr new file mode 100644 index 00000000..d2809d47 --- /dev/null +++ b/tests/trybuild/schedule/non_send_views.stderr @@ -0,0 +1,21 @@ +error[E0277]: `Rc` cannot be shared between threads safely + --> tests/trybuild/schedule/non_send_views.rs:35:24 + | +35 | world.run_schedule(&mut schedule); + | ------------ ^^^^^^^^^^^^^ `Rc` cannot be shared between threads safely + | | + | required by a bound introduced by this call + | + = help: the trait `Sync` is not implemented for `Rc` + = note: required for `&Rc` to implement `Send` + = note: required because it appears within the type `(&Rc, Null)` + = note: required for `brood::system::schedule::task::System` to implement `brood::system::schedule::task::sealed::Task<'_, (Rc, brood::registry::Null), brood::resource::Null, (registry::contains::Null, (registry::contains::Contained, registry::contains::Null), (registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), (resource::contains::Null, resource::contains::Null, resource::contains::Null, resource::contains::Null), (((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), view::disjoint::Null, ((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), view::disjoint::Null), ((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null)>` + = note: required for `(brood::system::schedule::task::System, brood::system::schedule::task::Null)` to implement `schedule::stager::Cutoff<'_, (Rc, brood::registry::Null), brood::resource::Null, schedule::claim::decision::Append, ((&Rc, brood::query::view::Null), schedule::claim::Null), schedule::stager::Null, schedule::stager::Null, schedule::stager::Null, schedule::stager::Null, (brood::query::view::Null, schedule::claim::Null), schedule::stager::Null, schedule::stager::Null, schedule::stager::Null, ((registry::contains::Null, (registry::contains::Contained, registry::contains::Null), (registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), schedule::stage::Null), ((resource::contains::Null, resource::contains::Null, resource::contains::Null, resource::contains::Null), schedule::stage::Null), ((((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), view::disjoint::Null, ((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), view::disjoint::Null), schedule::stage::Null), (((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), schedule::stage::Null)>` + = note: required for `(brood::system::schedule::task::System, brood::system::schedule::task::Null)` to implement `schedule::scheduler::Scheduler<'_, (Rc, brood::registry::Null), brood::resource::Null, ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), (((((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), ((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), (view::merge::Neither, (view::merge::Left, view::merge::Null))), schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), (((registry::contains::Null, (registry::contains::Contained, registry::contains::Null), (registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), schedule::stage::Null), schedule::stages::Null), (((resource::contains::Null, resource::contains::Null, resource::contains::Null, resource::contains::Null), schedule::stage::Null), schedule::stages::Null), (((((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), view::disjoint::Null, ((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), view::disjoint::Null), schedule::stage::Null), schedule::stages::Null), ((((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), schedule::stage::Null), schedule::stages::Null)>` + = note: required for `(brood::system::schedule::task::System, brood::system::schedule::task::Null)` to implement `schedule::sealed::Sealed<'_, (Rc, brood::registry::Null), brood::resource::Null, (((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), (((((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), ((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), (view::merge::Neither, (view::merge::Left, view::merge::Null))), schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), (((registry::contains::Null, (registry::contains::Contained, registry::contains::Null), (registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), schedule::stage::Null), schedule::stages::Null), (((resource::contains::Null, resource::contains::Null, resource::contains::Null, resource::contains::Null), schedule::stage::Null), schedule::stages::Null), (((((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), view::disjoint::Null, ((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), view::disjoint::Null), schedule::stage::Null), schedule::stages::Null), ((((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), schedule::stage::Null), schedule::stages::Null))>` + = note: required for `(brood::system::schedule::task::System, brood::system::schedule::task::Null)` to implement `Schedule<'_, (Rc, brood::registry::Null), brood::resource::Null, (((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::scheduler::Null), (((((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), ((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), (view::merge::Neither, (view::merge::Left, view::merge::Null))), schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), ((schedule::claim::Null, schedule::stager::Null), schedule::stages::Null), (((registry::contains::Null, (registry::contains::Contained, registry::contains::Null), (registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), schedule::stage::Null), schedule::stages::Null), (((resource::contains::Null, resource::contains::Null, resource::contains::Null, resource::contains::Null), schedule::stage::Null), schedule::stages::Null), (((((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), view::disjoint::Null, ((registry::contains::NotContained, (®istry::contains::Contained, registry::contains::Null)), (brood::hlist::get::Index, registry::contains::Null), (brood::hlist::get::Index, brood::hlist::Null)), view::disjoint::Null), schedule::stage::Null), schedule::stages::Null), ((((registry::contains::NotContained, (registry::contains::NotContained, registry::contains::Null)), registry::contains::Null, brood::hlist::Null), schedule::stage::Null), schedule::stages::Null))>` +note: required by a bound in `World::::run_schedule` + --> src/world/mod.rs + | + | Schedule: schedule::Schedule<'a, Registry, Resources, Indices>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `World::::run_schedule` diff --git a/tests/trybuild/schedule/type_unexpected_token.rs b/tests/trybuild/schedule/type_unexpected_token.rs index be031c2f..9c4e6aa7 100644 --- a/tests/trybuild/schedule/type_unexpected_token.rs +++ b/tests/trybuild/schedule/type_unexpected_token.rs @@ -1,4 +1,4 @@ -use brood::{query::{Views, filter, result, Result}, registry::ContainsQuery, system::{System, Schedule}}; +use brood::{query::{Views, filter, Result}, registry, system::{System, Schedule}}; // This import is technically unused, since the macro fails to compile before it would be consumed. // I'm leaving it here, though, for completeness; user code would use this module, and these tests // should do their best to simulate user code. @@ -14,11 +14,11 @@ impl System for A { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result, VI, P, I, Q>, Self::ResourceViews<'a>, Self::EntryViews<'a>, (EP, EI, EQ)>, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q> {} + R: registry::Registry, I: Iterator> {} } struct B; @@ -29,11 +29,11 @@ impl System for B { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result, VI, P, I, Q>, Self::ResourceViews<'a>, Self::EntryViews<'a>, (EP, EI, EQ)>, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q> {} + R: registry::Registry, I: Iterator> {} } type Schedule = Schedule!(task::System, + task::System,); diff --git a/tests/trybuild/schedule/unexpected_token.rs b/tests/trybuild/schedule/unexpected_token.rs index 901482ae..1bb8c59f 100644 --- a/tests/trybuild/schedule/unexpected_token.rs +++ b/tests/trybuild/schedule/unexpected_token.rs @@ -1,4 +1,4 @@ -use brood::{query::{Views, filter, result, Result}, registry::ContainsQuery, system::{System, schedule}}; +use brood::{query::{Views, filter, Result}, registry, system::{System, schedule}}; // This import is technically unused, since the macro fails to compile before it would be consumed. // I'm leaving it here, though, for completeness; user code would use this module, and these tests // should do their best to simulate user code. @@ -14,11 +14,11 @@ impl System for A { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result, VI, P, I, Q>, Self::ResourceViews<'a>, Self::EntryViews<'a>, (EP, EI, EQ)>, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q> {} + R: registry::Registry, I: Iterator> {} } struct B; @@ -29,11 +29,11 @@ impl System for B { type ResourceViews<'a> = Views!(); type EntryViews<'a> = Views!(); - fn run<'a, R, S, FI, VI, P, I, Q, EP, EI, EQ>( + fn run<'a, R, S, I, E>( &mut self, - _query_results: Result, VI, P, I, Q>, Self::ResourceViews<'a>, Self::EntryViews<'a>, (EP, EI, EQ)>, + _query_results: Result, Self::EntryViews<'a>, E>, ) where - R: ContainsQuery<'a, Self::Filter, FI, Self::Views<'a>, VI, P, I, Q> {} + R: registry::Registry, I: Iterator>, {} } fn main() {