!Send
and !Sync
Components
World
can store !Send
and/or !Sync
components once the thread_local
feature is set but they come with limitations:
!Send
storages can only be added inWorld
's thread.Send + !Sync
components can only be accessed from one thread at a time.!Send + Sync
components can only be accessed immutably from other threads.!Send + !Sync
components can only be accessed in the thread they were added in.
These storages are accessed with NonSend
, NonSync
and NonSendSync
, for example:
#[derive(Unique)]
struct RcU32(Rc<u32>);
#[derive(Component)]
struct RcUSIZE(Rc<usize>);
#[allow(unused)]
fn run(rcs_usize: NonSendSync<View<RcUSIZE>>, rc_u32: NonSendSync<UniqueView<RcU32>>) {}