@@ -1029,7 +1029,7 @@ impl<const CAPACITY: usize, Item, Gap> Chunk<CAPACITY, Item, Gap> {
10291029
10301030 match & self . content {
10311031 ChunkContent :: Gap ( ..) => Position ( identifier, 0 ) ,
1032- ChunkContent :: Items ( items) => Position ( identifier, items. len ( ) - 1 ) ,
1032+ ChunkContent :: Items ( items) => Position ( identifier, items. len ( ) . saturating_sub ( 1 ) ) ,
10331033 }
10341034 }
10351035
@@ -1606,6 +1606,14 @@ mod tests {
16061606 assert_matches ! ( iterator. next( ) , None ) ;
16071607 }
16081608
1609+ #[ test]
1610+ fn test_ritems_empty ( ) {
1611+ let linked_chunk = LinkedChunk :: < 2 , char , ( ) > :: new ( ) ;
1612+ let mut iterator = linked_chunk. ritems ( ) ;
1613+
1614+ assert_matches ! ( iterator. next( ) , None ) ;
1615+ }
1616+
16091617 #[ test]
16101618 fn test_items ( ) {
16111619 let mut linked_chunk = LinkedChunk :: < 2 , char , ( ) > :: new ( ) ;
@@ -1623,6 +1631,14 @@ mod tests {
16231631 assert_matches ! ( iterator. next( ) , None ) ;
16241632 }
16251633
1634+ #[ test]
1635+ fn test_items_empty ( ) {
1636+ let linked_chunk = LinkedChunk :: < 2 , char , ( ) > :: new ( ) ;
1637+ let mut iterator = linked_chunk. items ( ) ;
1638+
1639+ assert_matches ! ( iterator. next( ) , None ) ;
1640+ }
1641+
16261642 #[ test]
16271643 fn test_ritems_from ( ) -> Result < ( ) , Error > {
16281644 let mut linked_chunk = LinkedChunk :: < 2 , char , ( ) > :: new ( ) ;
0 commit comments