I have managed to get around my only use of unsafe (
*mut) by instead of letting the child mutate the data directly; pass back a vec of enums of actions to be taken, and have the parent conduct them instead.
however this requires a vec instantiation and allocation every time.
would it work better if the parent passed the child a &mut vec to allocate into?
1b) is there a way to 'pop()' items off (i don't care which order) that doesn't mess with the capacity?
i know the at most number of enums that will be returned.. but it's unlikely to reach that number often... should it return an array? or write into a &mut array kept by the parent?
what about something like tinyvec here or any other solution...
3b) If it helps, Child is the only person who will ever mutate that data, if say, i could give him a permanent
&mutthat would be fine, i guess?
also, what is the name of this pattern i am describing?