adamfortune.bsky.social
@adamfortune.bsky.social
I think you could replace starting at .collect() with

.map(|result| result .map(/* your Ok value logic */))
.take_until(|result| result .is_err()
.fold(|result| { let aggregate = result?/* rest of the fold logic here */ })

I use [take_until](docs.rs/take-until/l...), but take_while could work too
TakeUntilExt in take_until - Rust
TakeUntilExt is an extension trait for iterators. It adds the `Self::take_until` method.
docs.rs
December 4, 2025 at 1:27 PM
If I remember correctly, Result is an IntoIterator type, so you could flat_map instead of map if you’re just trying to ignore the Err’s.
December 4, 2025 at 3:58 AM
This is a solved problem. Check out serde.rs/attr-flatten...
Struct flattening · Serde
serde.rs
October 31, 2025 at 2:37 AM
I always struggle to stay motivated beyond ~day 12. Maybe I’ll actually finish AOC this year!
October 26, 2025 at 12:43 PM