diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-04-27 16:09:27 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-04-27 16:09:27 +0000 |
commit | bf645f3645fd2ee57495eafd1ccfb4afbe917bec (patch) | |
tree | 314e48f95e781e0e3b65dab7467e2fed4afafa47 /src/cmd/show_gen.rs | |
parent | 80aaff3f70f790141fbc8caa8a2f4830cd5e3fee (diff) | |
parent | 4ae0960619537234d5591b40d05f91b131330618 (diff) | |
download | obnam2-bf645f3645fd2ee57495eafd1ccfb4afbe917bec.tar.gz |
Merge branch 'feature/28-vec-to-iter' into 'main'
Return iterators instead of huge vectors
Closes #28
See merge request larswirzenius/obnam!142
Diffstat (limited to 'src/cmd/show_gen.rs')
-rw-r--r-- | src/cmd/show_gen.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/cmd/show_gen.rs b/src/cmd/show_gen.rs index ba39809..df8a030 100644 --- a/src/cmd/show_gen.rs +++ b/src/cmd/show_gen.rs @@ -21,16 +21,20 @@ impl ShowGeneration { let genlist = client.list_generations()?; let gen_id: String = genlist.resolve(&self.gen_id)?; let gen = client.fetch_generation(&gen_id, temp.path())?; - let files = gen.files()?; + let mut files = gen.files()?; + let mut files = files.iter()?; - let total_bytes = files.iter().fold(0, |acc, file| { - let e = file.entry(); - if e.kind() == FilesystemKind::Regular { - acc + file.entry().len() - } else { - acc - } + let total_bytes = files.try_fold(0, |acc, file| { + file.map(|file| { + let e = file.entry(); + if e.kind() == FilesystemKind::Regular { + acc + e.len() + } else { + acc + } + }) }); + let total_bytes = total_bytes?; println!("generation-id: {}", gen_id); println!("file-count: {}", gen.file_count()?); |