2021-06-03 01:41:37 -05:00
|
|
|
#![warn(clippy::suspicious_splitn)]
|
2021-12-06 05:33:31 -06:00
|
|
|
#![allow(clippy::needless_splitn)]
|
2021-06-03 01:41:37 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let _ = "a,b,c".splitn(3, ',');
|
|
|
|
let _ = [0, 1, 2, 1, 3].splitn(3, |&x| x == 1);
|
|
|
|
let _ = "".splitn(0, ',');
|
|
|
|
let _ = [].splitn(0, |&x: &u32| x == 1);
|
|
|
|
|
|
|
|
let _ = "a,b".splitn(0, ',');
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: `splitn` called with `0` splits
|
|
|
|
//~| NOTE: the resulting iterator will always return `None`
|
2021-06-03 01:41:37 -05:00
|
|
|
let _ = "a,b".rsplitn(0, ',');
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: `rsplitn` called with `0` splits
|
|
|
|
//~| NOTE: the resulting iterator will always return `None`
|
2021-06-03 01:41:37 -05:00
|
|
|
let _ = "a,b".splitn(1, ',');
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: `splitn` called with `1` split
|
|
|
|
//~| NOTE: the resulting iterator will always return the entire string followed by `No
|
2021-06-03 01:41:37 -05:00
|
|
|
let _ = [0, 1, 2].splitn(0, |&x| x == 1);
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: `splitn` called with `0` splits
|
|
|
|
//~| NOTE: the resulting iterator will always return `None`
|
2021-06-03 01:41:37 -05:00
|
|
|
let _ = [0, 1, 2].splitn_mut(0, |&x| x == 1);
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: `splitn_mut` called with `0` splits
|
|
|
|
//~| NOTE: the resulting iterator will always return `None`
|
2021-06-03 01:41:37 -05:00
|
|
|
let _ = [0, 1, 2].splitn(1, |&x| x == 1);
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: `splitn` called with `1` split
|
|
|
|
//~| NOTE: the resulting iterator will always return the entire slice followed by `Non
|
2021-06-03 01:41:37 -05:00
|
|
|
let _ = [0, 1, 2].rsplitn_mut(1, |&x| x == 1);
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: `rsplitn_mut` called with `1` split
|
|
|
|
//~| NOTE: the resulting iterator will always return the entire slice followed by `Non
|
2021-06-03 01:41:37 -05:00
|
|
|
|
|
|
|
const X: usize = 0;
|
|
|
|
let _ = "a,b".splitn(X + 1, ',');
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: `splitn` called with `1` split
|
|
|
|
//~| NOTE: the resulting iterator will always return the entire string followed by `No
|
2021-06-03 01:41:37 -05:00
|
|
|
let _ = "a,b".splitn(X, ',');
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: `splitn` called with `0` splits
|
|
|
|
//~| NOTE: the resulting iterator will always return `None`
|
2021-06-03 01:41:37 -05:00
|
|
|
}
|