This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ZipArchive is a bit cumbersome to use when you are consuming archives with unknown/variable contents, so this PR exposes 3 helper methods on ZipArchive to make it slightly easier to consume such content.
iter_files()
- Returns an iterator over the internal vector of ZipFileData, which allows people to use all of the standard iterator goodies they are used toby_id()
- As with the existing by_name/by_index, returns the ZipFile if that id exists. The id can be converted from a &ZipFileData and is unique (not name based)find()
- While iter_files().map() + by_id() or iter_files().position() + by_index() can be used to find a file matching criteria, they are a bit cumbersome to use due to the borrow checker since iter_files() is an immutable borrow and all of by_ methods are mutable, sofind
just wraps the most common case of "get me the file that matches this predicate, if it exists"