-
Type: New Feature
-
Resolution: Fixed
-
Priority: Critical - P2
-
Affects Version/s: 2.0.0-alpha.1
-
Component/s: None
-
None
Currently, the session used by a SessionCursorHandle cannot be reborrowed within the while let loop that iterates over the cursor. This makes using cursors with sessions pretty clunky.
repro:
let mut cursor = coll.find_with_session(doc! {}, None, &mut session).await? // cursor does not retain the reference, so it can be used here coll.run_command_with_session(doc! { "ping": 1 }, None, &mut session).await?; while let Some(doc) = cursor.with_session(&mut_session).next().await? { println!("{}", doc?); // following line errors saying the session is already borrowed coll.run_command_with_session(doc! { "ping": 1 }, None, &mut session).await?; }