use super::{
super::{error::*, problem::*},
r#ref::*,
};
pub struct CauseRefIterator<'problem> {
pub problem: &'problem Problem,
pub depth: usize,
}
impl<'problem> CauseRefIterator<'problem> {
pub fn new(problem: &'problem Problem, depth: usize) -> Self {
CauseRefIterator { problem, depth }
}
}
impl<'problem> Iterator for CauseRefIterator<'problem> {
type Item = CauseRef<'problem, CapturedError>;
fn next(&mut self) -> Option<Self::Item> {
let depth = self.depth;
self.depth += 1;
self.problem
.get(depth)
.map(|cause| cause.to_ref(self.problem, depth))
}
}