Closed GregoryConrad closed 5 months ago
As a note: the only way to do this safely without a set upper-bound size (16 above) is to use a linked list. That is both:
This is because each side effects needs to return a mut ref. Can't have multiple mutable borrows on the same object at the same time, unless you use something sneaky like split_at_mut
I still think I want to keep the default
register
api as-is, but I think a side effect (inrearch-effects
) like the following would be a nice touch:Note that in the above example, the backing array size could be 2. 16 is just chosen as a sane default.
This should be possible with 100% safe rust via
split_first_mut
: