about summary refs log tree commit diff
path: root/src/test/ui/async-await/async-block-control-flow-static-semantics.rs
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-08-17 11:13:42 +0200
committerGitHub <noreply@github.com>2019-08-17 11:13:42 +0200
commit477db0506658a7db06808e24c11a1f0514da7c1c (patch)
tree321b06903cbe9bcb87f348caed4e67ec84edc186 /src/test/ui/async-await/async-block-control-flow-static-semantics.rs
parente910be8d7c7c3ae00a2839b310cc4062d5de8163 (diff)
parent688c11216aca1d7449b07b3ebbcee3ba114d0d51 (diff)
downloadrust-477db0506658a7db06808e24c11a1f0514da7c1c.tar.gz
rust-477db0506658a7db06808e24c11a1f0514da7c1c.zip
Rollup merge of #62737 - timvermeulen:cycle_try_fold, r=scottmcm
Override Cycle::try_fold

It's not very pretty, but I believe this is the simplest way to correctly implement `Cycle::try_fold`. The following may seem correct:
```rust
loop {
    acc = self.iter.try_fold(acc, &mut f)?;
    self.iter = self.orig.clone();
}
```
...but this loops infinitely in case `self.orig` is empty, as opposed to returning `acc`. So we first have to fully iterate `self.orig` to check whether it is empty or not, and before _that_, we have to iterate the remaining elements of `self.iter`.

This should always call `self.orig.clone()` the same amount of times as repeated `next()` calls would.

r? @scottmcm
Diffstat (limited to 'src/test/ui/async-await/async-block-control-flow-static-semantics.rs')
0 files changed, 0 insertions, 0 deletions