summaryrefslogtreecommitdiffstats
path: root/tests/ui/dest-prop/skeptic-miscompile.rs
blob: 4bb61dbc7f400b14937506bec42e4f0580cf2fd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// run-pass

// compile-flags: -Zmir-opt-level=3

trait IterExt: Iterator {
    fn fold_ex<B, F>(mut self, init: B, mut f: F) -> B
    where
        Self: Sized,
        F: FnMut(B, Self::Item) -> B,
    {
        let mut accum = init;
        while let Some(x) = self.next() {
            accum = f(accum, x);
        }
        accum
    }
}

impl<T: Iterator> IterExt for T {}

fn main() {
    let test = &["\n"];
    test.iter().fold_ex(String::new(), |_, b| b.to_string());
}