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 @@ -309,17 +309,15 @@ impl<T> SessionCursor<T> {
309309 where
310310 D : Deserialize < ' a > ,
311311 {
312- let out = SessionCursor {
312+ SessionCursor {
313313 client : self . client . clone ( ) ,
314314 info : self . info . clone ( ) ,
315315 state : Some ( self . take_state ( ) ) ,
316316 drop_address : self . drop_address . take ( ) ,
317317 _phantom : Default :: default ( ) ,
318318 #[ cfg( test) ]
319319 kill_watcher : self . kill_watcher . take ( ) ,
320- } ;
321- self . mark_exhausted ( ) ; // prevent a `kill_cursor` call in `drop`
322- out
320+ }
323321 }
324322
325323 pub ( crate ) fn address ( & self ) -> & ServerAddress {
@@ -346,12 +344,8 @@ impl<T> SessionCursor<T> {
346344}
347345
348346impl < T > SessionCursor < T > {
349- fn mark_exhausted ( & mut self ) {
350- self . state . as_mut ( ) . unwrap ( ) . exhausted = true ;
351- }
352-
353347 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 )
355349 }
356350
357351 #[ 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