Open KSXGitHub opened 1 year ago
Note that care must be taken to consider each entry within an archive in sequence. If entries are processed out of sequence (from what the iterator returns), then the contents read for each entry may be corrupted.
As the docs state in the description of the entries
function, you cannot process the entries out of order., which is what you are doing. You have to process the entries one by one from what the iterator returns.
This isn't a bug, it's expected behavior.
In my case, tar always read file's content as empty.
For example, when I save the content as Hello
, but it shows '\0\0\0\0\0'.
assertion `left == right` failed
left: "\0\0\0\0\0"
right: "Hello"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
So I guess it's not a problem to use collect, but I think there are some problem with in-memory source?
-- edited
Nevermind my case, it become ok when I use for-loop instead of collect.
This isn't a bug, it's expected behavior.
I still think this should be caught at compile time somehow. Maybe an entry could hold a mutable reference to the associated entries list, so grabbing the next entry will alert the borrow checker?
Also, maybe this should be mentioned in the documentation more prominently. The pages for Entry and Entries do not mention this.
Steps to reproduce
reproduce.bash
Expected behavior
It prints the content of the files correctly.
Actual behavior
It prints empty strings as content.