You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Moved get_component(_unchecked_mut) from Query to QueryState (#9686)
# Objective
- Fixes#9683
## Solution
- Moved `get_component` from `Query` to `QueryState`.
- Moved `get_component_unchecked_mut` from `Query` to `QueryState`.
- Moved `QueryComponentError` from `bevy_ecs::system` to
`bevy_ecs::query`. Minor Breaking Change.
- Narrowed scope of `unsafe` blocks in `Query` methods.
---
## Migration Guide
- `use bevy_ecs::system::QueryComponentError;` -> `use
bevy_ecs::query::QueryComponentError;`
## Notes
I am not very familiar with unsafe Rust nor its use within Bevy, so I
may have committed a Rust faux pas during the migration.
---------
Co-authored-by: Zac Harrold <[email protected]>
Co-authored-by: Tristan Guichaoua <[email protected]>
/// An error that occurs when retrieving a specific [`Entity`]'s query result from [`Query`](crate::system::Query) or [`QueryState`](crate::query::QueryState).
6
+
// TODO: return the type_name as part of this error
7
+
#[derive(Debug,PartialEq,Eq,Clone,Copy)]
8
+
pubenumQueryEntityError{
9
+
/// The given [`Entity`]'s components do not match the query.
10
+
///
11
+
/// Either it does not have a requested component, or it has a component which the query filters out.
12
+
QueryDoesNotMatch(Entity),
13
+
/// The given [`Entity`] does not exist.
14
+
NoSuchEntity(Entity),
15
+
/// The [`Entity`] was requested mutably more than once.
16
+
///
17
+
/// See [`QueryState::get_many_mut`](crate::query::QueryState::get_many_mut) for an example.
/// The [`Query`](crate::system::Query) does not have write access to the requested component.
71
+
///
72
+
/// This error occurs when the requested component is not included in the original query, or the mutability of the requested component is mismatched with the original query.
73
+
///
74
+
/// # Example
75
+
///
76
+
/// ```
77
+
/// # use bevy_ecs::{prelude::*, query::QueryComponentError};
0 commit comments