in below/store/src/cursor.rs [77:93]
fn jump_to_key(&mut self, key: &Key, direction: Direction) -> Result<bool> {
self.jump_near_key(key, direction);
// Move cursor backward to get a position with lower key order, and then
// move forward to get the first position with higher key order.
let mut curr_key = self.get_key();
for curr_dir in &[direction.flip(), direction] {
let skip_order = curr_dir.get_skip_order();
while curr_key.as_ref().map_or(true, |k| k.cmp(key) == skip_order) {
if !self.advance(*curr_dir)? {
break;
}
curr_key = self.get_key();
}
}
// Check if the last key satisfies the direction order
Ok(curr_key.map_or(false, |k| k.cmp(key) != direction.get_skip_order()))
}