Closed meuter closed 1 year ago
No, ZipFile
needs a mutable borrow to its ZipArchive
(cf https://docs.rs/zip/latest/zip/read/struct.ZipArchive.html#method.by_index). This is because it needs a mutable access to the inner reader.
This means that you can't have several ZipFile
s alive at the same time. Furthermore, you can't write such an iterator.
Hi, that is a bit dissapointing, but hey at least now I understand why. Thanks for taking to time to explain, much appreciated!
Cheers
Hi,
I am trying to implement the
IntoIterator
trait for (a wrapper struct around)ZipArchive
. My thought was to create anEntries
struct that would own theZipArchive
with anindex
to keep track of which file we are at. Then implementIterator<Item=Result<ZipFile>>
for this struct. Here's what I have so far.However, I cannot figure out the lifetime of the
ZipFile
returned byZipArchive::by_index()
. I would have expected that it had the same lifetime as theZipArchive
itself, but the compiler seems to disagree:Is there anyway around this? What is the lifetime attached to the
ZipFile<'_>
? Is what I am trying to achieve even possible?Thanks in advance for any help you can provide.
-Cédric