Have iter_from/iter_dup_from return a Result (update of #7) #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The iter_from test in #7 is failing because MDB_SET_RANGE sets the "Position at first key greater than or equal to specified key." And
foo
is less thankey1
, the first key in the test store; socursor.iter_from(b"foo")
sets the cursor position to the first key and returns Ok instead of Err(NotFound).(The iter_dup_from test doesn't fail in the same way because
foo
is greater thanc
, the greatest key in that test's store.)This branch fixes the test by seeking to
key6
, which is greater than any key in the store, instead offoo
. It also adds tests to confirm that seeking to an intermediate key that doesn't exist (key4
in a store withkey3
andkey5
keys) will move the cursor's position to the next key greater than or equal to that key.NB: given LMDB's behavior when seeking to a nonexistent but intermediate key (which is actually quite useful for my use case), it isn't clear to me that an Err(NotFound) is the most ergonomic result of seeking to a nonexistent key that is greater than any in the store.
Returning an iterator over an empty set in that case would make the behavior more consistent, and it would be more usable for callers whose behavior doesn't depend on the presence of the given key (nor any greater ones).
Nevertheless, I haven't made that change in this branch. I'll request a pull with it on another branch for your consideration.