Skip to content

Commit

Permalink
implement k_iter and k_iter_mut on queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Frizi committed Mar 27, 2021
1 parent 94c4184 commit e0f9176
Show file tree
Hide file tree
Showing 5 changed files with 459 additions and 76 deletions.
27 changes: 27 additions & 0 deletions crates/bevy_ecs/src/query/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,18 @@ pub struct ReadFetch<T> {
sparse_set: *const ComponentSparseSet,
}

impl<T> Clone for ReadFetch<T> {
fn clone(&self) -> Self {
Self {
storage_type: self.storage_type,
table_components: self.table_components,
entity_table_rows: self.entity_table_rows,
entities: self.entities,
sparse_set: self.sparse_set,
}
}
}

/// SAFE: access is read only
unsafe impl<T> ReadOnlyFetch for ReadFetch<T> {}

Expand Down Expand Up @@ -340,6 +352,21 @@ pub struct WriteFetch<T> {
change_tick: u32,
}

impl<T> Clone for WriteFetch<T> {
fn clone(&self) -> Self {
Self {
storage_type: self.storage_type,
table_components: self.table_components,
table_ticks: self.table_ticks,
entities: self.entities,
entity_table_rows: self.entity_table_rows,
sparse_set: self.sparse_set,
last_change_tick: self.last_change_tick,
change_tick: self.change_tick,
}
}
}

pub struct WriteState<T> {
component_id: ComponentId,
storage_type: StorageType,
Expand Down
Loading

0 comments on commit e0f9176

Please sign in to comment.