]>
Commit | Line | Data |
---|---|---|
1 | #![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes, unused_must_use)] | |
2 | #![warn(clippy::single_char_pattern)] | |
3 | use std::collections::HashSet; | |
4 | ||
5 | fn main() { | |
6 | let x = "foo"; | |
7 | x.split("x"); | |
8 | x.split("xx"); | |
9 | x.split('x'); | |
10 | ||
11 | let y = "x"; | |
12 | x.split(y); | |
13 | x.split("ß"); | |
14 | x.split("ℝ"); | |
15 | x.split("💣"); | |
16 | // Can't use this lint for unicode code points which don't fit in a char | |
17 | x.split("❤️"); | |
18 | x.split_inclusive("x"); | |
19 | x.contains("x"); | |
20 | x.starts_with("x"); | |
21 | x.ends_with("x"); | |
22 | x.find("x"); | |
23 | x.rfind("x"); | |
24 | x.rsplit("x"); | |
25 | x.split_terminator("x"); | |
26 | x.rsplit_terminator("x"); | |
27 | x.splitn(2, "x"); | |
28 | x.rsplitn(2, "x"); | |
29 | x.split_once("x"); | |
30 | x.rsplit_once("x"); | |
31 | x.matches("x"); | |
32 | x.rmatches("x"); | |
33 | x.match_indices("x"); | |
34 | x.rmatch_indices("x"); | |
35 | x.trim_start_matches("x"); | |
36 | x.trim_end_matches("x"); | |
37 | x.replace("x", "y"); | |
38 | x.replacen("x", "y", 3); | |
39 | // Make sure we escape characters correctly. | |
40 | x.split("\n"); | |
41 | x.split("'"); | |
42 | x.split("\'"); | |
43 | // Issue #11973: Don't escape `"` in `'"'` | |
44 | x.split("\""); | |
45 | ||
46 | let h = HashSet::<String>::new(); | |
47 | h.contains("X"); // should not warn | |
48 | ||
49 | x.replace(';', ",").split(","); // issue #2978 | |
50 | x.starts_with("\x03"); // issue #2996 | |
51 | ||
52 | // Issue #3204 | |
53 | const S: &str = "#"; | |
54 | x.find(S); | |
55 | ||
56 | // Raw string | |
57 | x.split(r"a"); | |
58 | x.split(r#"a"#); | |
59 | x.split(r###"a"###); | |
60 | x.split(r###"'"###); | |
61 | x.split(r###"#"###); | |
62 | // Must escape backslash in raw strings when converting to char #8060 | |
63 | x.split(r#"\"#); | |
64 | x.split(r"\"); | |
65 | ||
66 | // should not warn, the char versions are actually slower in some cases | |
67 | x.strip_prefix("x"); | |
68 | x.strip_suffix("x"); | |
69 | } |