I am trying to create a function for a struct which loops calling a function on itself, having trouble with lifetimes
The problem is in this function
fn next<'b, 'out>(reader_: &mut Reader<B> ) -> Option<(&'out [u8], BytesStart<'out>)> {
let test = loop {
let Reader { reader, ns, buf } = reader_;
let e = reader
.read_namespaced_event(buf, ns)
.map(|(ns, e)| (ns.unwrap_or(&[]), e));
match e {
Ok((ns, Event::Start(start))) => {
break Some((ns, start));
}
_ => {}
}
};
test
}
I think the problem comes with the return value but i am not sure how to annotate the lifetimes.
Full code at: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=381cc6be43934c091b7444c4c8d80dfc
Using quick-xml.