@@ -94,9 +94,9 @@ impl From<Option<String>> for PaginationToken {
94
94
/// forward from it.
95
95
///
96
96
/// See also the module-level documentation.
97
- pub struct Paginator {
97
+ pub struct Paginator < PR : PaginableRoom > {
98
98
/// The room in which we're going to run the pagination.
99
- room : Box < dyn PaginableRoom > ,
99
+ room : PR ,
100
100
101
101
/// Current state of the paginator.
102
102
state : SharedObservable < PaginatorState > ,
@@ -113,7 +113,7 @@ pub struct Paginator {
113
113
}
114
114
115
115
#[ cfg( not( tarpaulin_include) ) ]
116
- impl std:: fmt:: Debug for Paginator {
116
+ impl < PR : PaginableRoom > std:: fmt:: Debug for Paginator < PR > {
117
117
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
118
118
// Don't include the room in the debug output.
119
119
f. debug_struct ( "Paginator" )
@@ -186,9 +186,9 @@ impl Drop for ResetStateGuard {
186
186
}
187
187
}
188
188
189
- impl Paginator {
189
+ impl < PR : PaginableRoom > Paginator < PR > {
190
190
/// Create a new [`Paginator`], given a room implementation.
191
- pub fn new ( room : Box < dyn PaginableRoom > ) -> Self {
191
+ pub fn new ( room : PR ) -> Self {
192
192
Self {
193
193
room,
194
194
state : SharedObservable :: new ( PaginatorState :: Initial ) ,
@@ -701,7 +701,7 @@ mod tests {
701
701
#[ async_test]
702
702
async fn test_start_from ( ) {
703
703
// Prepare test data.
704
- let room = Box :: new ( TestRoom :: new ( false , * ROOM_ID , * USER_ID ) ) ;
704
+ let room = TestRoom :: new ( false , * ROOM_ID , * USER_ID ) ;
705
705
706
706
let event_id = event_id ! ( "$yoyoyo" ) ;
707
707
let event_factory = & room. event_factory ;
@@ -749,7 +749,7 @@ mod tests {
749
749
#[ async_test]
750
750
async fn test_start_from_with_num_events ( ) {
751
751
// Prepare test data.
752
- let room = Box :: new ( TestRoom :: new ( false , * ROOM_ID , * USER_ID ) ) ;
752
+ let room = TestRoom :: new ( false , * ROOM_ID , * USER_ID ) ;
753
753
754
754
let event_id = event_id ! ( "$yoyoyo" ) ;
755
755
let event_factory = & room. event_factory ;
@@ -780,7 +780,7 @@ mod tests {
780
780
#[ async_test]
781
781
async fn test_paginate_backward ( ) {
782
782
// Prepare test data.
783
- let room = Box :: new ( TestRoom :: new ( false , * ROOM_ID , * USER_ID ) ) ;
783
+ let room = TestRoom :: new ( false , * ROOM_ID , * USER_ID ) ;
784
784
785
785
let event_id = event_id ! ( "$yoyoyo" ) ;
786
786
let event_factory = & room. event_factory ;
@@ -852,7 +852,7 @@ mod tests {
852
852
#[ async_test]
853
853
async fn test_paginate_backward_with_limit ( ) {
854
854
// Prepare test data.
855
- let room = Box :: new ( TestRoom :: new ( false , * ROOM_ID , * USER_ID ) ) ;
855
+ let room = TestRoom :: new ( false , * ROOM_ID , * USER_ID ) ;
856
856
857
857
let event_id = event_id ! ( "$yoyoyo" ) ;
858
858
let event_factory = & room. event_factory ;
@@ -896,7 +896,7 @@ mod tests {
896
896
#[ async_test]
897
897
async fn test_paginate_forward ( ) {
898
898
// Prepare test data.
899
- let room = Box :: new ( TestRoom :: new ( false , * ROOM_ID , * USER_ID ) ) ;
899
+ let room = TestRoom :: new ( false , * ROOM_ID , * USER_ID ) ;
900
900
901
901
let event_id = event_id ! ( "$yoyoyo" ) ;
902
902
let event_factory = & room. event_factory ;
@@ -967,7 +967,7 @@ mod tests {
967
967
968
968
#[ async_test]
969
969
async fn test_state ( ) {
970
- let room = Box :: new ( TestRoom :: new ( true , * ROOM_ID , * USER_ID ) ) ;
970
+ let room = TestRoom :: new ( true , * ROOM_ID , * USER_ID ) ;
971
971
972
972
* room. prev_batch_token . lock ( ) . await = Some ( "prev" . to_owned ( ) ) ;
973
973
* room. next_batch_token . lock ( ) . await = Some ( "next" . to_owned ( ) ) ;
@@ -1107,7 +1107,7 @@ mod tests {
1107
1107
1108
1108
#[ async_test]
1109
1109
async fn test_abort_while_starting_from ( ) {
1110
- let room = Box :: new ( AbortingRoom :: default ( ) ) ;
1110
+ let room = AbortingRoom :: default ( ) ;
1111
1111
1112
1112
let paginator = Arc :: new ( Paginator :: new ( room. clone ( ) ) ) ;
1113
1113
@@ -1140,7 +1140,7 @@ mod tests {
1140
1140
1141
1141
#[ async_test]
1142
1142
async fn test_abort_while_paginating ( ) {
1143
- let room = Box :: new ( AbortingRoom :: default ( ) ) ;
1143
+ let room = AbortingRoom :: default ( ) ;
1144
1144
1145
1145
// Assuming a paginator ready to back- or forward- paginate,
1146
1146
let paginator = Paginator :: new ( room. clone ( ) ) ;
0 commit comments