Fix bug in split_before and split_after for first and last node edge cases - #19
Fix bug in split_before and split_after for first and last node edge cases#19morlinbrot wants to merge 2 commits into
Conversation
|
Note the differences in implementation between this and the same fix over at too-many-lists. |
|
I've checked your new solution - it looks like all stuff works fine:
|
|
I'll look into this |
|
Just rebased this to solve the merge conflicts. @pczarn, if you have the time, I'd love for you to have another look. |
|
I did. Just need to fix those 1.67 and 1.68 and we release it. |
Co-authored-by: Peter Blackson <pioczarn@gmail.com>
Thanks. From your wording I can't tell, do you want me to fix the CI issues or are you looking into it? The issues arise from Simplest solution would be to increase this lib's MSRV, is this something you'd consider? I'd be happy to create a separate PR for that if you want. |
|
On a second thought, I will do it myself and yours will get automatically rebased on top of my changes to the CI because we need an aggregate |
|
Github's repo settings do not seem to play nice with our renaming of CI jobs when msrv gets bumped. |
Fixes #18
The
split_beforeandsplit_aftermethods don't handle the edge case of being at the first or last node correctly.Example
split_before:In the current implementation,
output_frontwill be set to the list's head before checking if there actually is a node before where the cursor currently is, which in the case of being at the first node will not be the case. In this case, we want to return an empty list which can be done by simply not setting a new head.I tried to implement a fix as unobtrusive to the original implementation as possible, since I assume that the methods are written with readability in mind for the too-many-lists project. In my implementation, I wrote the methods a bit more "cleverly" which may be not as easy to follow but shorter and more focused on all the edge cases that need to be covered, here's a snippet of it:
Let me know if you'd be interested in switching to my implementation, I'd be glad to update the PR.