Commit a4e0832
committed
Fix
When `pop_front` was called while the cursor pointed to the front element, `move_next` incremented the index but it was never decremented afterwards, causing the index to incorrectly report 1 instead of 0.
Always decrement the index after popping from front using `saturating_sub` to handle edge cases safely.
Fixes #147616LinkedList::CursorMut::pop_front to correctly update index1 parent 31010ca commit a4e0832
File tree
2 files changed
+58
-2
lines changed- library/alloc/src/collections
- linked_list
2 files changed
+58
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1855 | 1855 | | |
1856 | 1856 | | |
1857 | 1857 | | |
1858 | | - | |
1859 | | - | |
1860 | 1858 | | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
1861 | 1863 | | |
1862 | 1864 | | |
1863 | 1865 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
748 | 748 | | |
749 | 749 | | |
750 | 750 | | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
751 | 805 | | |
752 | 806 | | |
753 | 807 | | |
| |||
0 commit comments