pub unsafe trait IterQueryData: QueryData { }Expand description
A QueryData for which instances may be alive for different entities concurrently.
Rust Iterators don’t connect the lifetime in Iterator::next to anything in Iterator::Item,
so later calls don’t invalidate earlier items.
This is how methods like Iterator::collect work.
It is therefore unsound to offer an Iterator for a QueryData for which only one instance may be alive concurrently.
To iterate over a QueryData that does not implement IterQueryData,
use the QueryIter::fetch_next() method.
For QueryData that implement this trait, QueryData::fetch may be called for one entity while an item is still alive for a different entity.
All SingleEntityQueryData types are IterQueryData.
They only access data on the current entity, the one passed to QueryData::fetch,
so the access for different entities will always be disjoint.
All ReadOnlyQueryData types are IterQueryData.
Even if they access data on entities other than the current one,
that access is read-only and it’s sound for it to alias.
Queries with a nested query that performs mutable access should generally not be IterQueryData,
although they can be if they have a way to prove that all accesses through the nested query are disjoint.
§Safety
This QueryData must not perform conflicting access when fetched for different entities.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.