Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,14 @@ pub struct PreparedQuery<Q: Query> {
fetch: Box<[Option<Q::Fetch>]>,
}

// Safety: `Fetch::State` is `Send`, and cached fetches encode access to query
// items, which this bound permits transferring between threads.
unsafe impl<Q: Query> Send for PreparedQuery<Q> where for<'a> Q::Item<'a>: Send {}

// Safety: `Fetch::State` is `Sync`, and cached fetches cannot be accessed
// through a shared reference because every such method requires `&mut self`.
unsafe impl<Q: Query> Sync for PreparedQuery<Q> {}

impl<Q: Query> Default for PreparedQuery<Q> {
fn default() -> Self {
Self::new()
Expand Down