@@ -16,6 +16,7 @@ impl ReceivedMessageSnapshot {
1616}
1717
1818/// A participant's view of their received messages
19+ #[ derive( Default ) ]
1920struct ParticipantSnapshot {
2021 // `snaps` is a list of (participant, messages) pairs
2122 snaps : Vec < ReceivedMessageSnapshot > ,
@@ -25,13 +26,6 @@ struct ParticipantSnapshot {
2526}
2627
2728impl ParticipantSnapshot {
28- pub fn new_empty ( ) -> Self {
29- Self {
30- snaps : Vec :: new ( ) ,
31- read_index : 0 ,
32- }
33- }
34-
3529 fn push_received_message_snapshot ( & mut self , snap : ReceivedMessageSnapshot ) {
3630 self . snaps . push ( snap) ;
3731 }
@@ -66,7 +60,7 @@ impl ProtocolSnapshot {
6660 pub fn new_empty ( participants : Vec < Participant > ) -> Self {
6761 let snapshots = participants
6862 . into_iter ( )
69- . map ( |p| ( p, ParticipantSnapshot :: new_empty ( ) ) )
63+ . map ( |p| ( p, ParticipantSnapshot :: default ( ) ) )
7064 . collect :: < HashMap < _ , _ > > ( ) ;
7165 Self { snapshots }
7266 }
@@ -125,7 +119,7 @@ mod test {
125119
126120 #[ test]
127121 fn test_read_next_message ( ) {
128- let mut psnap = ParticipantSnapshot :: new_empty ( ) ;
122+ let mut psnap = ParticipantSnapshot :: default ( ) ;
129123 let mut rvec = Vec :: new ( ) ;
130124 let mut rng = MockCryptoRng :: seed_from_u64 ( 123_123 ) ;
131125 for _ in 0 ..50 {
@@ -142,7 +136,7 @@ mod test {
142136
143137 #[ test]
144138 fn test_refresh_read_all ( ) {
145- let mut psnap = ParticipantSnapshot :: new_empty ( ) ;
139+ let mut psnap = ParticipantSnapshot :: default ( ) ;
146140 let mut rng = MockCryptoRng :: seed_from_u64 ( 123_123 ) ;
147141 for _ in 0 ..50 {
148142 let received_snap = generate_random_received_snap ( & mut rng) ;
0 commit comments