Returns true if `f` returns true for any node in the tree. Stops recursion as soon as a matching node is found
(&self, mut f: F)
| 395 | /// |
| 396 | /// Stops recursion as soon as a matching node is found |
| 397 | fn exists<F: FnMut(&Self) -> Result<bool>>(&self, mut f: F) -> Result<bool> { |
| 398 | let mut found = false; |
| 399 | self.apply(|n| { |
| 400 | Ok(if f(n)? { |
| 401 | found = true; |
| 402 | TreeNodeRecursion::Stop |
| 403 | } else { |
| 404 | TreeNodeRecursion::Continue |
| 405 | }) |
| 406 | }) |
| 407 | .map(|_| found) |
| 408 | } |
| 409 | |
| 410 | /// Low-level API used to implement other APIs. |
| 411 | /// |