summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/skip_while_next.rs
blob: 8e4cd82cec3060ebc1c9fd40ca11890d820257e9 (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
25
26
27
28
29
//@aux-build:option_helpers.rs

#![warn(clippy::skip_while_next)]
#![allow(clippy::disallowed_names, clippy::useless_vec)]

extern crate option_helpers;
use option_helpers::IteratorFalsePositives;

#[rustfmt::skip]
fn skip_while_next() {
    let v = vec![3, 2, 1, 0, -1, -2, -3];

    // Single-line case.
    let _ = v.iter().skip_while(|&x| *x < 0).next();

    // Multi-line case.
    let _ = v.iter().skip_while(|&x| {
                                *x < 0
                            }
                   ).next();

    // Check that hat we don't lint if the caller is not an `Iterator`.
    let foo = IteratorFalsePositives { foo: 0 };
    let _ = foo.skip_while().next();
}

fn main() {
    skip_while_next();
}