| 408 | Ok(()) |
| 409 | } |
| 410 | fn visit_pre_post<F1, F2>(&self, pre: &mut F1, post: &mut F2) |
| 411 | where |
| 412 | F1: FnMut(&Self) -> Option<Vec<&Self>>, |
| 413 | F2: FnMut(&Self), |
| 414 | { |
| 415 | use VisitAction::*; |
| 416 | let mut stack = vec![Enter(self)]; |
| 417 | while let Some(action) = stack.pop() { |
| 418 | match action { |
| 419 | Enter(elt) => { |
| 420 | stack.push(Leave(elt)); |
| 421 | if let Some(children) = pre(elt) { |
| 422 | for child in children.into_iter().rev() { |
| 423 | stack.push(Enter(child)); |
| 424 | } |
| 425 | } else { |
| 426 | for child in elt.children().rev() { |
| 427 | stack.push(Enter(child)); |
| 428 | } |
| 429 | } |
| 430 | } |
| 431 | Leave(elt) => { |
| 432 | post(elt); |
| 433 | } |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | #[allow(clippy::as_conversions)] |
| 439 | fn visit_mut_pre_post<F1, F2>(&mut self, pre: &mut F1, post: &mut F2) |