It feels like maybe this could be a code structure issue, but within your example what about something like this?
<span style="color:#323232;">fn main(){
</span><span style="color:#323232;"> let mut counter = 0;
</span><span style="color:#323232;"> let output_array = array.into_iter()
</span><span style="color:#323232;"> .map(|single_item| {
</span><span style="color:#323232;"> // breaks the map if the array when trying to access an item past 5
</span><span style="color:#323232;"> if single_item > 5 {
</span><span style="color:#323232;"> break;
</span><span style="color:#323232;"> }
</span><span style="color:#323232;"> })
</span><span style="color:#323232;"> .collect()
</span><span style="color:#323232;"> .map(|single_item| {
</span><span style="color:#323232;"> // increment a variable outside of this scope that's mutable that can be changed by the previous run
</span><span style="color:#323232;"> counter += 1;
</span><span style="color:#323232;"> single_item.function(counter);
</span><span style="color:#323232;"> })
</span><span style="color:#323232;"> .collect();
</span><span style="color:#323232;">}
</span>
Does that kinda syntax work for your workflow? Maybe it’ll require you to either pollute a single map (or similar) with a bunch of checks that you can use to trigger a break though.
Most of the time I’ve been able to find ways to re-write them in this syntax, but I also think that rusts borrowing system although fantastic for confidence in your code makes refactoring an absolute nightmare so often it’s too much of a hassle to rewrite my code with a better syntax.