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 @@ -309,17 +309,15 @@ impl<T> SessionCursor<T> {
309
309
where
310
310
D : Deserialize < ' a > ,
311
311
{
312
- let out = SessionCursor {
312
+ SessionCursor {
313
313
client : self . client . clone ( ) ,
314
314
info : self . info . clone ( ) ,
315
315
state : Some ( self . take_state ( ) ) ,
316
316
drop_address : self . drop_address . take ( ) ,
317
317
_phantom : Default :: default ( ) ,
318
318
#[ cfg( test) ]
319
319
kill_watcher : self . kill_watcher . take ( ) ,
320
- } ;
321
- self . mark_exhausted ( ) ; // prevent a `kill_cursor` call in `drop`
322
- out
320
+ }
323
321
}
324
322
325
323
pub ( crate ) fn address ( & self ) -> & ServerAddress {
@@ -346,12 +344,8 @@ impl<T> SessionCursor<T> {
346
344
}
347
345
348
346
impl < T > SessionCursor < T > {
349
- fn mark_exhausted ( & mut self ) {
350
- self . state . as_mut ( ) . unwrap ( ) . exhausted = true ;
351
- }
352
-
353
347
pub ( crate ) fn is_exhausted ( & self ) -> bool {
354
- self . state . as_ref ( ) . unwrap ( ) . exhausted
348
+ self . state . as_ref ( ) . map_or ( true , |state| state . exhausted )
355
349
}
356
350
357
351
#[ 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