@@ -78,7 +78,6 @@ impl Offset {
7878 }
7979}
8080
81- // TODO: implement Debug
8281/// One element of the topic partition list.
8382pub struct TopicPartitionListElem < ' a > {
8483 ptr : & ' a mut RDKafkaTopicPartition ,
@@ -165,6 +164,18 @@ impl<'a> PartialEq for TopicPartitionListElem<'a> {
165164 }
166165}
167166
167+ impl fmt:: Debug for TopicPartitionListElem < ' _ > {
168+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
169+ f. debug_struct ( "TopicPartitionListElem" )
170+ . field ( "topic" , & self . topic ( ) )
171+ . field ( "partition" , & self . partition ( ) )
172+ . field ( "offset" , & self . offset ( ) )
173+ . field ( "metadata" , & self . metadata ( ) )
174+ . field ( "error" , & self . error ( ) )
175+ . finish ( )
176+ }
177+ }
178+
168179/// A structure to store and manipulate a list of topics and partitions with optional offsets.
169180pub struct TopicPartitionList {
170181 ptr : NativePtr < RDKafkaTopicPartitionList > ,
@@ -389,22 +400,7 @@ impl Default for TopicPartitionList {
389400
390401impl fmt:: Debug for TopicPartitionList {
391402 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
392- write ! ( f, "TPL {{" ) ?;
393- for ( i, elem) in self . elements ( ) . iter ( ) . enumerate ( ) {
394- if i > 0 {
395- write ! ( f, "; " ) ?;
396- }
397- write ! (
398- f,
399- "{}/{}: offset={:?} metadata={:?}, error={:?}" ,
400- elem. topic( ) ,
401- elem. partition( ) ,
402- elem. offset( ) ,
403- elem. metadata( ) ,
404- elem. error( ) ,
405- ) ?;
406- }
407- write ! ( f, "}}" )
403+ f. debug_list ( ) . entries ( self . elements ( ) ) . finish ( )
408404 }
409405}
410406
0 commit comments