Hi guys, I’m super new to rust (like since Thursday) so please bear with me
As an exercise, I’d like to implement
ZipArchive using fn by_index<'a>(&'a mut self, file_number: usize) -> ZipResult< ZipFile<'a> > in order to iterate over the files inside because it would feel much more natural than for loop.
I’m banging my head over this for couple of evenings now, and I’m beginning to feel that it’s plain impossible.
I tried dozens of ways to structure my code but nothing seems to go my way.
Once I thought I had it, but then I realized I implemented an
Iterator for a struct that can’t ever be instantiated .
I’m easily able to implement iterator returning an index into the
ZipArchive, but there’s no point in doing it as you basically get the for loop.
My question is: is it possible? If so, please give me a hint. In case this can’t be done without
unsafe I’d appreciate a code example as I didn’t yet grasp that part of language too much.