How do I share a struct containing a phantom pointer among threads?
问题 I have a structure that needs to be generic over a type, yet the type is not actually contained in the structure: it's used in methods of this structure, not in the structure itself. And so, the structure includes a PhantomData member: pub struct Map<T> { filename: String, phantom: PhantomData<*const T>, } The phantom member is defined as a pointer because the structure does not actually own data of type T . This is per advice in the documentation of std::marker::PhantomData: Adding a field