HighlightState with a non-empty initial_stack crashing?
Hi,
I'm trying to build a HighlightState with a cached initial_stack, as described in the docs:
Alternatively you can save space by caching only the
pathfield of this struct then re-create theHighlightStatewhen needed by passing that stack as theinitial_stackparameter to thenewmethod. This takes less space but a small amount of time to re-create the style stack.
I'm probably missing something (very new to rust), but to me it appears this is guaranteed to crash:
The first call to update_single_cache_for_push in HighlightState::new, will pass path of length 0, which results in path.len() - 1 panicking with attempt to subtract with overflow.
Is there an example somewhere of code using HighlightState with a non-empty initial_stack? What am I missing?
Thanks ahead, and many thanks for building this incredible library!
Hi, thanks for reporting. It's possible that there are currently no unit tests covering this scenario, and that you are the first person to try using it... I will investigate when I'm able to make time, but maybe someone else will beat me to it :)
Yup seems right, this path indeed doesn't seem to be tested. I might look into it this weekend if I have time, but no guarantees.