Skip to content

Commit e30199f

Browse files
committed
Document bevy_tasks and enable #![warn(missing_docs)] (#3509)
This PR is part of the issue #3492. # Objective - Add and update the bevy_tasks documentation to achieve a 100% documentation coverage (sans `prelude` module) - Add the #![warn(missing_docs)] lint to keep the documentation coverage for the future. ## Solution - Add and update the bevy_math documentation. - Add the #![warn(missing_docs)] lint. - Added doctest wherever there should be in the missing docs.
1 parent 71814ca commit e30199f

File tree

6 files changed

+211
-94
lines changed

6 files changed

+211
-94
lines changed

benches/benches/bevy_tasks/iter.rs

-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ impl<'a, T> ParallelIterator<std::slice::Iter<'a, T>> for ParChunks<'a, T>
66
where
77
T: 'a + Send + Sync,
88
{
9-
type Item = &'a T;
10-
119
fn next_batch(&mut self) -> Option<std::slice::Iter<'a, T>> {
1210
self.0.next().map(|s| s.iter())
1311
}
@@ -18,8 +16,6 @@ impl<'a, T> ParallelIterator<std::slice::IterMut<'a, T>> for ParChunksMut<'a, T>
1816
where
1917
T: 'a + Send + Sync,
2018
{
21-
type Item = &'a mut T;
22-
2319
fn next_batch(&mut self) -> Option<std::slice::IterMut<'a, T>> {
2420
self.0.next().map(|s| s.iter_mut())
2521
}

crates/bevy_tasks/src/iter/adapters.rs

+17-39
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ pub struct Chain<T, U> {
1010
impl<B, T, U> ParallelIterator<B> for Chain<T, U>
1111
where
1212
B: Iterator + Send,
13-
T: ParallelIterator<B, Item = B::Item>,
14-
U: ParallelIterator<B, Item = T::Item>,
13+
T: ParallelIterator<B>,
14+
U: ParallelIterator<B>,
1515
{
16-
type Item = T::Item;
17-
1816
fn next_batch(&mut self) -> Option<B> {
1917
if self.left_in_progress {
2018
match self.left.next_batch() {
@@ -35,11 +33,9 @@ pub struct Map<P, F> {
3533
impl<B, U, T, F> ParallelIterator<std::iter::Map<B, F>> for Map<U, F>
3634
where
3735
B: Iterator + Send,
38-
U: ParallelIterator<B, Item = B::Item>,
39-
F: FnMut(U::Item) -> T + Send + Clone,
36+
U: ParallelIterator<B>,
37+
F: FnMut(B::Item) -> T + Send + Clone,
4038
{
41-
type Item = T;
42-
4339
fn next_batch(&mut self) -> Option<std::iter::Map<B, F>> {
4440
self.iter.next_batch().map(|b| b.map(self.f.clone()))
4541
}
@@ -54,11 +50,9 @@ pub struct Filter<P, F> {
5450
impl<B, P, F> ParallelIterator<std::iter::Filter<B, F>> for Filter<P, F>
5551
where
5652
B: Iterator + Send,
57-
P: ParallelIterator<B, Item = B::Item>,
58-
F: FnMut(&P::Item) -> bool + Send + Clone,
53+
P: ParallelIterator<B>,
54+
F: FnMut(&B::Item) -> bool + Send + Clone,
5955
{
60-
type Item = P::Item;
61-
6256
fn next_batch(&mut self) -> Option<std::iter::Filter<B, F>> {
6357
self.iter
6458
.next_batch()
@@ -75,11 +69,9 @@ pub struct FilterMap<P, F> {
7569
impl<B, P, R, F> ParallelIterator<std::iter::FilterMap<B, F>> for FilterMap<P, F>
7670
where
7771
B: Iterator + Send,
78-
P: ParallelIterator<B, Item = B::Item>,
79-
F: FnMut(P::Item) -> Option<R> + Send + Clone,
72+
P: ParallelIterator<B>,
73+
F: FnMut(B::Item) -> Option<R> + Send + Clone,
8074
{
81-
type Item = R;
82-
8375
fn next_batch(&mut self) -> Option<std::iter::FilterMap<B, F>> {
8476
self.iter.next_batch().map(|b| b.filter_map(self.f.clone()))
8577
}
@@ -94,13 +86,11 @@ pub struct FlatMap<P, F> {
9486
impl<B, P, U, F> ParallelIterator<std::iter::FlatMap<B, U, F>> for FlatMap<P, F>
9587
where
9688
B: Iterator + Send,
97-
P: ParallelIterator<B, Item = B::Item>,
98-
F: FnMut(P::Item) -> U + Send + Clone,
89+
P: ParallelIterator<B>,
90+
F: FnMut(B::Item) -> U + Send + Clone,
9991
U: IntoIterator,
10092
U::IntoIter: Send,
10193
{
102-
type Item = U::Item;
103-
10494
// This extends each batch using the flat map. The other option is
10595
// to turn each IntoIter into its own batch.
10696
fn next_batch(&mut self) -> Option<std::iter::FlatMap<B, U, F>> {
@@ -116,12 +106,10 @@ pub struct Flatten<P> {
116106
impl<B, P> ParallelIterator<std::iter::Flatten<B>> for Flatten<P>
117107
where
118108
B: Iterator + Send,
119-
P: ParallelIterator<B, Item = B::Item>,
109+
P: ParallelIterator<B>,
120110
B::Item: IntoIterator,
121111
<B::Item as IntoIterator>::IntoIter: Send,
122112
{
123-
type Item = <P::Item as IntoIterator>::Item;
124-
125113
// This extends each batch using the flatten. The other option is to
126114
// turn each IntoIter into its own batch.
127115
fn next_batch(&mut self) -> Option<std::iter::Flatten<B>> {
@@ -137,10 +125,8 @@ pub struct Fuse<P> {
137125
impl<B, P> ParallelIterator<B> for Fuse<P>
138126
where
139127
B: Iterator + Send,
140-
P: ParallelIterator<B, Item = B::Item>,
128+
P: ParallelIterator<B>,
141129
{
142-
type Item = P::Item;
143-
144130
fn next_batch(&mut self) -> Option<B> {
145131
match &mut self.iter {
146132
Some(iter) => match iter.next_batch() {
@@ -164,11 +150,9 @@ pub struct Inspect<P, F> {
164150
impl<B, P, F> ParallelIterator<std::iter::Inspect<B, F>> for Inspect<P, F>
165151
where
166152
B: Iterator + Send,
167-
P: ParallelIterator<B, Item = B::Item>,
168-
F: FnMut(&P::Item) + Send + Clone,
153+
P: ParallelIterator<B>,
154+
F: FnMut(&B::Item) + Send + Clone,
169155
{
170-
type Item = P::Item;
171-
172156
fn next_batch(&mut self) -> Option<std::iter::Inspect<B, F>> {
173157
self.iter.next_batch().map(|b| b.inspect(self.f.clone()))
174158
}
@@ -182,11 +166,9 @@ pub struct Copied<P> {
182166
impl<'a, B, P, T> ParallelIterator<std::iter::Copied<B>> for Copied<P>
183167
where
184168
B: Iterator<Item = &'a T> + Send,
185-
P: ParallelIterator<B, Item = &'a T>,
169+
P: ParallelIterator<B>,
186170
T: 'a + Copy,
187171
{
188-
type Item = T;
189-
190172
fn next_batch(&mut self) -> Option<std::iter::Copied<B>> {
191173
self.iter.next_batch().map(|b| b.copied())
192174
}
@@ -200,11 +182,9 @@ pub struct Cloned<P> {
200182
impl<'a, B, P, T> ParallelIterator<std::iter::Cloned<B>> for Cloned<P>
201183
where
202184
B: Iterator<Item = &'a T> + Send,
203-
P: ParallelIterator<B, Item = &'a T>,
185+
P: ParallelIterator<B>,
204186
T: 'a + Copy,
205187
{
206-
type Item = T;
207-
208188
fn next_batch(&mut self) -> Option<std::iter::Cloned<B>> {
209189
self.iter.next_batch().map(|b| b.cloned())
210190
}
@@ -219,10 +199,8 @@ pub struct Cycle<P> {
219199
impl<B, P> ParallelIterator<B> for Cycle<P>
220200
where
221201
B: Iterator + Send,
222-
P: ParallelIterator<B, Item = B::Item> + Clone,
202+
P: ParallelIterator<B> + Clone,
223203
{
224-
type Item = P::Item;
225-
226204
fn next_batch(&mut self) -> Option<B> {
227205
match self.curr.as_mut().and_then(|c| c.next_batch()) {
228206
batch @ Some(_) => batch,

0 commit comments

Comments
 (0)