blob: efc47533e233761616307ad60e8061627a3077af (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
//@edition:2018
#![warn(clippy::needless_splitn)]
#![allow(clippy::iter_skip_next, clippy::iter_nth_zero, clippy::manual_split_once)]
extern crate itertools;
#[allow(unused_imports)]
use itertools::Itertools;
fn main() {
let str = "key=value=end";
let _ = str.split('=').next();
let _ = str.split('=').nth(0);
let _ = str.splitn(2, '=').nth(1);
let (_, _) = str.splitn(2, '=').next_tuple().unwrap();
let (_, _) = str.split('=').next_tuple().unwrap();
let _: Vec<&str> = str.splitn(3, '=').collect();
let _ = str.rsplit('=').next();
let _ = str.rsplit('=').nth(0);
let _ = str.rsplitn(2, '=').nth(1);
let (_, _) = str.rsplitn(2, '=').next_tuple().unwrap();
let (_, _) = str.rsplit('=').next_tuple().unwrap();
let _ = str.split('=').next();
let _ = str.split('=').nth(3);
let _ = str.splitn(5, '=').nth(4);
let _ = str.splitn(5, '=').nth(5);
}
fn _question_mark(s: &str) -> Option<()> {
let _ = s.split('=').next()?;
let _ = s.split('=').nth(0)?;
let _ = s.rsplit('=').next()?;
let _ = s.rsplit('=').nth(0)?;
Some(())
}
#[clippy::msrv = "1.51"]
fn _test_msrv() {
// `manual_split_once` MSRV shouldn't apply to `needless_splitn`
let _ = "key=value".split('=').nth(0).unwrap();
}
|