Skip to content

Commit f26119e

Browse files
psimonyiphimuemue
authored andcommitted
Implement Debug for remaining public types
Implement `Debug` for the `ChunkBy`-related types. Also derive it for two `Coalesce`-related types; I'm not sure they are actually exposed but the compiler thinks so, and it's easy to do. There are no more public types without a `Debug` impl (at least a conditional one) so enable warning for missing `Debug` implementations.
1 parent f6e349a commit f26119e

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

src/adaptors/coalesce.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ where
110110
{
111111
}
112112

113+
#[derive(Debug)]
113114
pub struct NoCount;
114115

116+
#[derive(Debug)]
115117
pub struct WithCount;
116118

117119
pub trait CountItem<T> {

src/groupbylazy.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use alloc::vec::{self, Vec};
22
use std::cell::{Cell, RefCell};
3+
use std::fmt::Debug;
34

45
/// A trait to unify `FnMut` for `ChunkBy` with the chunk key in `IntoChunks`
56
trait KeyFunction<A> {
@@ -76,6 +77,27 @@ where
7677
dropped_group: usize,
7778
}
7879

80+
impl<K, I, F> Debug for GroupInner<K, I, F>
81+
where
82+
K: Debug,
83+
I: Iterator + Debug,
84+
I::Item: Debug,
85+
{
86+
debug_fmt_fields!(
87+
GroupInner,
88+
// key, omitted because functions are almost never Debug
89+
iter,
90+
current_key,
91+
current_elt,
92+
done,
93+
top_group,
94+
oldest_buffered_group,
95+
bottom_group,
96+
buffer,
97+
dropped_group
98+
);
99+
}
100+
79101
impl<K, I, F> GroupInner<K, I, F>
80102
where
81103
I: Iterator,
@@ -311,6 +333,15 @@ where
311333
index: Cell<usize>,
312334
}
313335

336+
impl<K, I, F> Debug for ChunkBy<K, I, F>
337+
where
338+
K: Debug,
339+
I: Iterator + Debug,
340+
I::Item: Debug,
341+
{
342+
debug_fmt_fields!(ChunkBy, inner, index);
343+
}
344+
314345
/// Create a new
315346
pub fn new<K, J, F>(iter: J, f: F) -> ChunkBy<K, J::IntoIter, F>
316347
where
@@ -385,6 +416,15 @@ where
385416
parent: &'a ChunkBy<K, I, F>,
386417
}
387418

419+
impl<'a, K, I, F> Debug for Groups<'a, K, I, F>
420+
where
421+
K: Debug,
422+
I: Iterator + Debug,
423+
I::Item: Debug,
424+
{
425+
debug_fmt_fields!(Groups, parent);
426+
}
427+
388428
impl<'a, K, I, F> Iterator for Groups<'a, K, I, F>
389429
where
390430
I: Iterator,
@@ -438,6 +478,15 @@ where
438478
}
439479
}
440480

481+
impl<'a, K, I, F> Debug for Group<'a, K, I, F>
482+
where
483+
K: Debug,
484+
I: Iterator + Debug,
485+
I::Item: Debug,
486+
{
487+
debug_fmt_fields!(Group, parent, index, first);
488+
}
489+
441490
impl<'a, K, I, F> Iterator for Group<'a, K, I, F>
442491
where
443492
I: Iterator,
@@ -503,6 +552,14 @@ where
503552
index: Cell<usize>,
504553
}
505554

555+
impl<I> Debug for IntoChunks<I>
556+
where
557+
I: Iterator + Debug,
558+
I::Item: Debug,
559+
{
560+
debug_fmt_fields!(IntoChunks, inner, index);
561+
}
562+
506563
impl<I> Clone for IntoChunks<I>
507564
where
508565
I: Clone + Iterator,
@@ -554,6 +611,14 @@ where
554611
parent: &'a IntoChunks<I>,
555612
}
556613

614+
impl<'a, I> Debug for Chunks<'a, I>
615+
where
616+
I: Iterator + Debug,
617+
I::Item: Debug,
618+
{
619+
debug_fmt_fields!(Chunks, parent);
620+
}
621+
557622
impl<'a, I> Iterator for Chunks<'a, I>
558623
where
559624
I: Iterator,
@@ -577,6 +642,7 @@ where
577642
/// An iterator for the elements in a single chunk.
578643
///
579644
/// Iterator element type is `I::Item`.
645+
#[derive(Debug)]
580646
pub struct Chunk<'a, I>
581647
where
582648
I: Iterator + 'a,

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![warn(missing_docs, clippy::default_numeric_fallback)]
2+
#![warn(missing_debug_implementations)]
23
#![crate_name = "itertools"]
34
#![cfg_attr(not(feature = "use_std"), no_std)]
45
#![doc(test(attr(deny(warnings), allow(deprecated, unstable_name_collisions))))]

0 commit comments

Comments
 (0)