1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//! Crate provides a way for tracking initialized to the world types,
//! automatically initializing components into the world on add
//! and conveniently adding system during runtime.
//!
//! # Motivation
//!
//! Sometimes it's impossible, or will be way too hard, to initialize everything on the
//! stage of building the app.
//!
//! For example:
//! ```
//! # use bevy_ecs::prelude::*;
//! # use bevy_ecs::world::DeferredWorld;
//! 
//! #[derive(Component)]
//! struct GenericComponent<A, B>(A, B)
//!     where A: Send + Sync + 'static, B: Send + Sync + 'static;
//!
//! fn system_operating_on_generic_component<A, B>(query: Query<&GenericComponent<A, B>>)
//!     where A: Send + Sync + 'static, B: Send + Sync + 'static 
//! {
//!     // do_something ...
//! }
//! ```
//!
//! Usual way to use generic types in bevy's ecs is to provide a method to register all
//! data, related to the generic parameter, to the world.
//! For example, [`add_event`](https://docs.rs/bevy/latest/bevy/app/struct.App.html#method.add_event)
//! registers all necessary data to the app so that it is possible to work with the registered event.
//! This way of handling generics should still be preferred, because it avoids unnecessary runtime checks.
//! 
//! But in the situation above, for it to be possible, user should register every possible combination of two generics 
//! beforehand for the program to work. And situation gets progressively worse with the increase in amount of generics.
//! 
//! So, with this library you can do this:
//! ```
//! # use bevy_ecs::prelude::*;
//! # use bevy_ecs::world::DeferredWorld;
//! # use bevy_app::Update;
//! use bevy_register_in_world::prelude::*;
//!
//! #[derive(ComponentAutoRegister)]
//! struct GenericComponent<A, B>(A, B)
//!     where A: Send + Sync + 'static, B: Send + Sync + 'static;
//!
//! impl<A, B> RegisterInWorld for GenericComponent<A, B> 
//!     where A: Send + Sync + 'static, B: Send + Sync + 'static
//! {
//!     fn register(mut world: DeferredWorld) {
//!         world.add_systems(Update, system_operating_on_generic_component::<A, B>);
//!     }
//! }
//! 
//! fn system_operating_on_generic_component<A, B>(query: Query<&GenericComponent<A, B>>) 
//!     where A: Send + Sync + 'static, B: Send + Sync + 'static
//! {
//!     // do_something ...
//! }
//! ```
//! And when component with unique combination of generics is added,
//! `register` is called during it's `on_add` hook.
extern crate self as bevy_register_in_world;
// unsure if this is the right thing to do
//pub mod system_param;
use ;
use ;
use TypeId;
/// Types that can be registered to the world.
type TypeIdSet = ;
/// Stores a `HashSet` of types that were registered into the world using [`RegisterInWorld`] trait.
/// Trait that is implemented for world and app types for convenience of registering.