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
pub use ;
use crate::;
use ParViewSeal;
/// A parallel view over a single aspect of an entity.
///
/// The main difference between this trait and the standard [`View`] trait is that this view can be
/// shared between threads, allowing it to be used within parallel iteration in either a
/// [`ParSystem`] or a [`par_query`].
///
/// All types that implement `View` also implement `ParView`, so long as any [`Component`] `C` they
/// view is [`Send`] when viewed mutably or [`Sync`] when viewed immutably.
///
/// # Example
/// ``` rust
/// // Define a component.
/// struct Foo(usize);
///
/// // Define a view over that component.
/// type FooView<'a> = &'a Foo;
/// ```
///
/// Because the `Component` viewed in the above example implements `Sync`, the view created above
/// implements `ParView`.
///
/// [`Component`]: crate::component::Component
/// [`ParSystem`]: crate::system::ParSystem
/// [`par_query`]: crate::world::World::par_query()
/// [`View`]: crate::query::view::View
/// A heterogeneous list of [`ParView`]s.
///
/// The main difference between this trait and the standard [`Views`] trait is that these views can
/// be shared between threads, allowing them to be used within parallel iteration in either a
/// [`ParSystem`] or a [`par_query`].
///
/// All types that implement `Views` also implement `ParViews`, so long as any [`Component`]s `C`
/// they view are [`Send`] when viewed mutably or [`Sync`] when viewed immutably.
///
/// # Example
/// ``` rust
/// use brood::query::Views;
///
/// // Define components.
/// struct Foo(usize);
/// struct Bar(bool);
///
/// // Define views over those components.
/// type Views<'a> = Views!(&'a Foo, &'a mut Bar);
/// ```
///
/// Because the `Component`s viewed above implement both [`Send`] and [`Sync`], the views created
/// above implement `ParViews`.
///
/// [`Component`]: crate::component::Component
/// [`ParSystem`]: crate::system::ParSystem
/// [`ParView`]: crate::query::view::ParView
/// [`par_query`]: crate::world::World::par_query()
/// [`Views`]: trait@crate::query::view::Views