Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-337

Consider returning an error when iterating a dead cursor

    • Type: Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      The Swift driver returns errors when users begin iterating a dead cursor:

      for x in cursor {
          // no errors in here
      }
      print(cursor.next()) // LogicError("cannot iterate a dead cursor")
      

      We should consider doing something similar in the Rust driver.

      The rationale for doing so is that a user iterating a dead cursor is probably indicative of a programmer error:

      • In the "eager" cursor, it could only happen if they're not using a while let loop or if they start iterating after their while let loop ended, both likely errors.
      • In the "non-eager" case, it means they're not distinguishing between a cursor being exhausted and returning None, which is also usually an error since it can lead to infinite loops.

            Assignee:
            Unassigned Unassigned
            Reporter:
            patrick.freed@mongodb.com Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: