I would like to accomplish something along those lines:
let todo_list = // fill with items
while let Some(next_item) = todo_list.pop() {
// work on task
// here comes the tricky part
let some_subtask = // identify related task
if let Some(subtask) = todo_list.remove(some_subtask) {
// work on the subtask
// this one does not spawn subtasks
}
}
In my case the tasks are identified by an index type with some random value in it. Therefore I tried a few things with HashSet
but those didn't seem to work too well. I am still too unfamiliar with the borrow checker to write acceptable code in this case.