假设我有以下结构:
pub struct Foo {
pub i: i32
}
pub struct Bar<'a> {
pub foo: &'a Foo
}
impl<'a> Bar<'a> {
fn make_baz(&self) -> Baz {
Baz { bar: self }
}
}
pub struct Baz<'a, 'b: 'a> {
pub bar: &'a Bar<'b>
}
是否可以像以下那样使用Iterator:
impl<'a> Iterator for Bar<'a> {
// how do I get this lifetime in here?
type Item = Baz<_, 'a>;
fn next(&mut self) -> Option<Self::Item> {
Some(self.make_baz())
}
}