@@ -22,7 +22,7 @@ use ruma::{
2222} ;
2323use serde:: { Deserialize , Serialize } ;
2424
25- use crate :: debug:: DebugRawEvent ;
25+ use crate :: debug:: { DebugRawEvent , DebugStructExt } ;
2626
2727const AUTHENTICITY_NOT_GUARANTEED : & str =
2828 "The authenticity of this encrypted message can't be guaranteed on this device." ;
@@ -257,11 +257,13 @@ impl SyncTimelineEvent {
257257impl fmt:: Debug for SyncTimelineEvent {
258258 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
259259 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 ( )
265267 }
266268}
267269
@@ -310,11 +312,13 @@ impl TimelineEvent {
310312impl fmt:: Debug for TimelineEvent {
311313 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
312314 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 ( )
318322 }
319323}
320324
0 commit comments