File tree 2 files changed +33
-9
lines changed
2 files changed +33
-9
lines changed Original file line number Diff line number Diff line change @@ -311,7 +311,7 @@ impl<T> SessionCursor<T> {
311
311
where
312
312
D : Deserialize < ' a > ,
313
313
{
314
- let out = SessionCursor {
314
+ SessionCursor {
315
315
client : self . client . clone ( ) ,
316
316
drop_token : self . drop_token . take ( ) ,
317
317
info : self . info . clone ( ) ,
@@ -320,9 +320,7 @@ impl<T> SessionCursor<T> {
320
320
_phantom : Default :: default ( ) ,
321
321
#[ cfg( test) ]
322
322
kill_watcher : self . kill_watcher . take ( ) ,
323
- } ;
324
- self . mark_exhausted ( ) ; // prevent a `kill_cursor` call in `drop`
325
- out
323
+ }
326
324
}
327
325
328
326
pub ( crate ) fn address ( & self ) -> & ServerAddress {
@@ -349,12 +347,8 @@ impl<T> SessionCursor<T> {
349
347
}
350
348
351
349
impl < T > SessionCursor < T > {
352
- fn mark_exhausted ( & mut self ) {
353
- self . state . as_mut ( ) . unwrap ( ) . exhausted = true ;
354
- }
355
-
356
350
pub ( crate ) fn is_exhausted ( & self ) -> bool {
357
- self . state . as_ref ( ) . unwrap ( ) . exhausted
351
+ self . state . as_ref ( ) . map_or ( true , |state| state . exhausted )
358
352
}
359
353
360
354
#[ cfg( test) ]
Original file line number Diff line number Diff line change @@ -235,3 +235,33 @@ async fn borrowed_deserialization() {
235
235
i += 1 ;
236
236
}
237
237
}
238
+
239
+ #[ cfg_attr( feature = "tokio-runtime" , tokio:: test) ]
240
+ #[ cfg_attr( feature = "async-std-runtime" , async_std:: test) ]
241
+ async fn session_cursor_with_type ( ) {
242
+ let _guard: RwLockReadGuard < ( ) > = LOCK . run_concurrently ( ) . await ;
243
+ let client = TestClient :: new ( ) . await ;
244
+
245
+ let mut session = client. start_session ( None ) . await . unwrap ( ) ;
246
+ let coll = client. database ( "db" ) . collection ( "coll" ) ;
247
+ coll. drop_with_session ( None , & mut session) . await . unwrap ( ) ;
248
+
249
+ coll. insert_many_with_session (
250
+ vec ! [ doc! { "x" : 1 } , doc! { "x" : 2 } , doc! { "x" : 3 } ] ,
251
+ None ,
252
+ & mut session,
253
+ )
254
+ . await
255
+ . unwrap ( ) ;
256
+
257
+ let mut cursor: crate :: SessionCursor < bson:: Document > = coll
258
+ . find_with_session ( doc ! { } , None , & mut session)
259
+ . await
260
+ . unwrap ( ) ;
261
+
262
+ let _ = cursor. next ( & mut session) . await . unwrap ( ) . unwrap ( ) ;
263
+
264
+ let mut cursor_with_type: crate :: SessionCursor < bson:: RawDocumentBuf > = cursor. with_type ( ) ;
265
+
266
+ let _ = cursor_with_type. next ( & mut session) . await . unwrap ( ) . unwrap ( ) ;
267
+ }
You can’t perform that action at this time.
0 commit comments