File tree Expand file tree Collapse file tree 2 files changed +33
-9
lines changed
Expand file tree Collapse file tree 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> {
311311 where
312312 D : Deserialize < ' a > ,
313313 {
314- let out = SessionCursor {
314+ SessionCursor {
315315 client : self . client . clone ( ) ,
316316 drop_token : self . drop_token . take ( ) ,
317317 info : self . info . clone ( ) ,
@@ -320,9 +320,7 @@ impl<T> SessionCursor<T> {
320320 _phantom : Default :: default ( ) ,
321321 #[ cfg( test) ]
322322 kill_watcher : self . kill_watcher . take ( ) ,
323- } ;
324- self . mark_exhausted ( ) ; // prevent a `kill_cursor` call in `drop`
325- out
323+ }
326324 }
327325
328326 pub ( crate ) fn address ( & self ) -> & ServerAddress {
@@ -349,12 +347,8 @@ impl<T> SessionCursor<T> {
349347}
350348
351349impl < T > SessionCursor < T > {
352- fn mark_exhausted ( & mut self ) {
353- self . state . as_mut ( ) . unwrap ( ) . exhausted = true ;
354- }
355-
356350 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 )
358352 }
359353
360354 #[ cfg( test) ]
Original file line number Diff line number Diff line change @@ -235,3 +235,33 @@ async fn borrowed_deserialization() {
235235 i += 1 ;
236236 }
237237}
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