@@ -22,7 +22,7 @@ use ruma::{
22
22
} ;
23
23
use serde:: { Deserialize , Serialize } ;
24
24
25
- use crate :: debug:: DebugRawEvent ;
25
+ use crate :: debug:: { DebugRawEvent , DebugStructExt } ;
26
26
27
27
const AUTHENTICITY_NOT_GUARANTEED : & str =
28
28
"The authenticity of this encrypted message can't be guaranteed on this device." ;
@@ -257,11 +257,13 @@ impl SyncTimelineEvent {
257
257
impl fmt:: Debug for SyncTimelineEvent {
258
258
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
259
259
let SyncTimelineEvent { event, encryption_info, push_actions } = self ;
260
- f. debug_struct ( "SyncTimelineEvent" )
261
- . field ( "event" , & DebugRawEvent ( event) )
262
- . field ( "encryption_info" , encryption_info)
263
- . field ( "push_actions" , push_actions)
264
- . finish ( )
260
+ let mut s = f. debug_struct ( "SyncTimelineEvent" ) ;
261
+ s. field ( "event" , & DebugRawEvent ( event) ) ;
262
+ s. maybe_field ( "encryption_info" , encryption_info) ;
263
+ if !push_actions. is_empty ( ) {
264
+ s. field ( "push_actions" , push_actions) ;
265
+ }
266
+ s. finish ( )
265
267
}
266
268
}
267
269
@@ -310,11 +312,13 @@ impl TimelineEvent {
310
312
impl fmt:: Debug for TimelineEvent {
311
313
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
312
314
let TimelineEvent { event, encryption_info, push_actions } = self ;
313
- f. debug_struct ( "TimelineEvent" )
314
- . field ( "event" , & DebugRawEvent ( event) )
315
- . field ( "encryption_info" , encryption_info)
316
- . field ( "push_actions" , push_actions)
317
- . finish ( )
315
+ let mut s = f. debug_struct ( "TimelineEvent" ) ;
316
+ s. field ( "event" , & DebugRawEvent ( event) ) ;
317
+ s. maybe_field ( "encryption_info" , encryption_info) ;
318
+ if !push_actions. is_empty ( ) {
319
+ s. field ( "push_actions" , push_actions) ;
320
+ }
321
+ s. finish ( )
318
322
}
319
323
}
320
324
0 commit comments