Skip to content

Commit

Permalink
explicitly identify reference in match patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
mykmelez committed Dec 1, 2018
1 parent 09d7656 commit af923dc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ impl <'txn> Iterator for Iter<'txn> {

fn next(&mut self) -> Option<Result<(&'txn [u8], &'txn [u8])>> {
match self {
Iter::Ok { cursor, ref mut op, next_op, _marker } => {
&mut Iter::Ok { cursor, ref mut op, next_op, _marker } => {
let mut key = ffi::MDB_val { mv_size: 0, mv_data: ptr::null_mut() };
let mut data = ffi::MDB_val { mv_size: 0, mv_data: ptr::null_mut() };
let op = mem::replace(op, *next_op);
let op = mem::replace(op, next_op);
unsafe {
match ffi::mdb_cursor_get(*cursor, &mut key, &mut data, op) {
match ffi::mdb_cursor_get(cursor, &mut key, &mut data, op) {
ffi::MDB_SUCCESS => Some(Ok((val_to_slice(key), val_to_slice(data)))),
// EINVAL can occur when the cursor was previously seeked to a non-existent value,
// e.g. iter_from with a key greater than all values in the database.
Expand All @@ -276,7 +276,7 @@ impl <'txn> Iterator for Iter<'txn> {
}
}
},
Iter::Err(err) => Some(Err(*err)),
&mut Iter::Err(err) => Some(Err(err)),
}
}
}
Expand Down Expand Up @@ -329,21 +329,21 @@ impl <'txn> Iterator for IterDup<'txn> {

fn next(&mut self) -> Option<Iter<'txn>> {
match self {
IterDup::Ok { cursor, ref mut op, _marker } => {
&mut IterDup::Ok { cursor, ref mut op, _marker } => {
let mut key = ffi::MDB_val { mv_size: 0, mv_data: ptr::null_mut() };
let mut data = ffi::MDB_val { mv_size: 0, mv_data: ptr::null_mut() };
let op = mem::replace(op, ffi::MDB_NEXT_NODUP);
let err_code = unsafe {
ffi::mdb_cursor_get(*cursor, &mut key, &mut data, op)
ffi::mdb_cursor_get(cursor, &mut key, &mut data, op)
};

if err_code == ffi::MDB_SUCCESS {
Some(Iter::new(*cursor, ffi::MDB_GET_CURRENT, ffi::MDB_NEXT_DUP))
Some(Iter::new(cursor, ffi::MDB_GET_CURRENT, ffi::MDB_NEXT_DUP))
} else {
None
}
},
IterDup::Err(err) => Some(Iter::Err(*err)),
&mut IterDup::Err(err) => Some(Iter::Err(err)),
}
}
}
Expand Down

0 comments on commit af923dc

Please sign in to comment.