@@ -23,8 +23,9 @@ impl<'a, K, V> ForwardInMemoryCursor<'a, K, V> {
2323 self . is_empty
2424 }
2525
26+ /// Returns the current entry pointed to be the cursor, or `None` if no entries are left.
2627 #[ inline]
27- fn peek ( & self ) -> Option < & ( K , V ) > {
28+ pub fn current ( & self ) -> Option < & ( K , V ) > {
2829 self . entries . clone ( ) . next ( )
2930 }
3031
5960 fn advance_while ( & mut self , predicate : impl Fn ( & K ) -> bool ) -> Option < ( K , V ) > {
6061 let mut entry;
6162 loop {
62- entry = self . peek ( ) ;
63+ entry = self . current ( ) ;
6364 if entry. is_some_and ( |( k, _) | predicate ( k) ) {
6465 self . next ( ) ;
6566 } else {
@@ -77,20 +78,21 @@ mod tests {
7778 #[ test]
7879 fn test_cursor ( ) {
7980 let mut cursor = ForwardInMemoryCursor :: new ( & [ ( 1 , ( ) ) , ( 2 , ( ) ) , ( 3 , ( ) ) , ( 4 , ( ) ) , ( 5 , ( ) ) ] ) ;
81+ assert_eq ! ( cursor. current( ) , Some ( & ( 1 , ( ) ) ) ) ;
8082
8183 assert_eq ! ( cursor. seek( & 0 ) , Some ( ( 1 , ( ) ) ) ) ;
82- assert_eq ! ( cursor. peek ( ) , Some ( & ( 1 , ( ) ) ) ) ;
84+ assert_eq ! ( cursor. current ( ) , Some ( & ( 1 , ( ) ) ) ) ;
8385
8486 assert_eq ! ( cursor. seek( & 3 ) , Some ( ( 3 , ( ) ) ) ) ;
85- assert_eq ! ( cursor. peek ( ) , Some ( & ( 3 , ( ) ) ) ) ;
87+ assert_eq ! ( cursor. current ( ) , Some ( & ( 3 , ( ) ) ) ) ;
8688
8789 assert_eq ! ( cursor. seek( & 3 ) , Some ( ( 3 , ( ) ) ) ) ;
88- assert_eq ! ( cursor. peek ( ) , Some ( & ( 3 , ( ) ) ) ) ;
90+ assert_eq ! ( cursor. current ( ) , Some ( & ( 3 , ( ) ) ) ) ;
8991
9092 assert_eq ! ( cursor. seek( & 4 ) , Some ( ( 4 , ( ) ) ) ) ;
91- assert_eq ! ( cursor. peek ( ) , Some ( & ( 4 , ( ) ) ) ) ;
93+ assert_eq ! ( cursor. current ( ) , Some ( & ( 4 , ( ) ) ) ) ;
9294
9395 assert_eq ! ( cursor. seek( & 6 ) , None ) ;
94- assert_eq ! ( cursor. peek ( ) , None ) ;
96+ assert_eq ! ( cursor. current ( ) , None ) ;
9597 }
9698}
0 commit comments