nonempty icon indicating copy to clipboard operation
nonempty copied to clipboard

remove methods

Open KaranJain21 opened this issue 5 months ago • 1 comments

Adds the following methods

  • checked_remove: checks if the element at a certain index can be removed from the vector, then removes it, shifting all elements after it to the left. If it is not possible to remove, returns a RemoveError
  • remove: calls checked_remove, then unwraps
  • checked_swap_remove: checks if the element at a certain index can be removed from the vector, then removes it, replacing it with the last element. If it is not possible to remove, returns a RemoveError
  • swap_remove: calls checked_swap_remove, then unwraps

All of the above methods return the removed element (if any).

Also add a RemoveError enum, with two variants:

  1. LengthOne: to avoid removing from a NonEmpty of length 1
  2. IndexOutOfBounds: for index larger than or equal to the length of the NonEmpty

KaranJain21 avatar Jul 30 '25 00:07 KaranJain21