Skip to content

Commit ca3832c

Browse files
committed
Ignore InnerT when implementing Send/Sync for RootNode (unsafe)
1 parent e5167e1 commit ca3832c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/schema/model.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ pub struct RootNode<InnerT, QueryT, MutationT=()> {
2121
phantom_wrapped: PhantomData<InnerT>,
2222
}
2323

24+
// RootNode implements Send + Sync if both the mutation type and query
25+
// type implements them. SchemaType also needs to implement them.
26+
//
27+
// InnerT does _not_ need to implement Send + Sync because it does not
28+
// actually appear in the struct.
29+
unsafe impl<InnerT, QueryT, MutationT> Send for RootNode<InnerT, QueryT, MutationT>
30+
where QueryT: Send, MutationT: Send, SchemaType: Send { }
31+
32+
unsafe impl<InnerT, QueryT, MutationT> Sync for RootNode<InnerT, QueryT, MutationT>
33+
where QueryT: Sync, MutationT: Sync, SchemaType: Sync { }
34+
2435
/// Metadata for a schema
2536
pub struct SchemaType {
2637
types: HashMap<String, MetaType>,

0 commit comments

Comments
 (0)