From ca6afa0cf981b2c36632ca6e621612b8b9be5676 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 1 Mar 2023 19:16:09 +0100 Subject: [PATCH] main: return list of region coordinates from process_region_dir() --- src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 76cebde..cf1f003 100644 --- a/src/main.rs +++ b/src/main.rs @@ -102,7 +102,9 @@ impl RegionProcessor { } /// Iterates over all region files of a Minecraft save directory - fn process_region_dir(&self, regiondir: &Path) -> Result<()> { + /// + /// Returns a list of the coordinates of all processed regions + fn process_region_dir(&self, regiondir: &Path) -> Result> { let read_dir = regiondir .read_dir() .with_context(|| format!("Failed to read directory {}", regiondir.display()))?; @@ -114,6 +116,8 @@ impl RegionProcessor { ) })?; + let mut ret = Vec::new(); + for entry in read_dir.filter_map(|entry| entry.ok()).filter(|entry| { // We are only interested in regular files entry @@ -132,9 +136,11 @@ impl RegionProcessor { coords.0, coords.1, err, ); } + + ret.push(coords); } - Ok(()) + Ok(ret) } }